diff options
author | ramverma <ram.krishna.verma@ericsson.com> | 2018-07-24 17:36:53 +0100 |
---|---|---|
committer | ramverma <ram.krishna.verma@ericsson.com> | 2018-07-25 11:47:15 +0100 |
commit | d524cedc578ae1bfa3bae895b3170f87463cbed9 (patch) | |
tree | 0740644e356534f770d59ff34f16e5d9ca601276 /examples | |
parent | 41ecf036b7f1b3bdd56311a0bc706407b242faca (diff) |
Adding more examples to apex-pdp
- Adding more examples (DecisionMaker, Periodic & ONAPvCPE) to apex-pdp.
- Fixed CORS issue in plugin-event-carrier-restserver module.
Added a ContainerResponseFilter to intercept every request/response coming to
REST server and add the required headers to support CORS.
Change-Id: Ic3e36c683f2a78992ce1417d2c00233b34066f2f
Issue-ID: POLICY-861
Signed-off-by: ramverma <ram.krishna.verma@ericsson.com>
Diffstat (limited to 'examples')
57 files changed, 3445 insertions, 0 deletions
diff --git a/examples/examples-decisionmaker/pom.xml b/examples/examples-decisionmaker/pom.xml new file mode 100644 index 000000000..09264447c --- /dev/null +++ b/examples/examples-decisionmaker/pom.xml @@ -0,0 +1,74 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 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========================================================= +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.apex-pdp.examples</groupId> + <artifactId>examples</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <artifactId>examples-decisionmaker</artifactId> + <name>${project.artifactId}</name> + <description>Specific code for the APEX Decision Maker Example</description> + + <properties> + <policymodel.name>DecisionMakerPolicyModel</policymodel.name> + <apex-domains-decisionmaker-dir>${project.basedir}/src</apex-domains-decisionmaker-dir> + </properties> + + <dependencies> + <dependency> + <groupId>org.onap.policy.apex-pdp.auth</groupId> + <artifactId>cli-editor</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Generate the APEX Policy JSON from the APEX CLI command --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-policy</id> + <phase>compile</phase> + <goals> + <goal>java</goal> + </goals> + <configuration> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <classpathScope>compile</classpathScope> + <arguments> + <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> + <argument>--output-model-file=${project.build.directory}/classes/${policymodel.name}.json</argument> + <argument>--log-file=${project.build.directory}/${policymodel.name}_policygeneration.log</argument> + <argument>--working-dir=${project.basedir}</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/AnswerInitTask.js b/examples/examples-decisionmaker/src/main/resources/logic/AnswerInitTask.js new file mode 100644 index 000000000..59074963a --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/AnswerInitTask.js @@ -0,0 +1,47 @@ +/* + * ============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 answerAlbum = executor.getContextAlbum("AnswerAlbum"); + +answerAlbum.put("a0", executor.inFields.get("a0")); +answerAlbum.put("a1", executor.inFields.get("a1")); +answerAlbum.put("a2", executor.inFields.get("a2")); +answerAlbum.put("a3", executor.inFields.get("a3")); +answerAlbum.put("a4", executor.inFields.get("a4")); +answerAlbum.put("a5", executor.inFields.get("a5")); +answerAlbum.put("a6", executor.inFields.get("a6")); + +var lastAnswerAlbum = executor.getContextAlbum("LastAnswerAlbum"); +lastAnswerAlbum.put("lastAnswer", answerAlbum.size() - 1); + +executor.outFields.put("a0", answerAlbum.get("a0")); +executor.outFields.put("a1", answerAlbum.get("a1")); +executor.outFields.put("a2", answerAlbum.get("a2")); +executor.outFields.put("a3", answerAlbum.get("a3")); +executor.outFields.put("a4", answerAlbum.get("a4")); +executor.outFields.put("a5", answerAlbum.get("a5")); +executor.outFields.put("a6", answerAlbum.get("a6")); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/DitheringAnswerTask.js b/examples/examples-decisionmaker/src/main/resources/logic/DitheringAnswerTask.js new file mode 100644 index 000000000..ec3455851 --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/DitheringAnswerTask.js @@ -0,0 +1,37 @@ +/* + * ============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 size = executor.getContextAlbum("AnswerAlbum").size(); + +var selection = 2 + Math.floor(Math.random() * 3); + +var selectionA = "a" + selection; + +executor.logger.info(size); +executor.logger.info(selectionA); + +executor.outFields.put("decision", executor.getContextAlbum("AnswerAlbum").get(selectionA)); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js b/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js new file mode 100644 index 000000000..93261e2e0 --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js @@ -0,0 +1,42 @@ +/* + * ============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.TRUE; + +if (executor.inFields.get("mode").equals("random")) { + executor.subject.getTaskKey("RandomAnswerTask").copyTo(executor.selectedTask); +} +else if (executor.inFields.get("mode").equals("pessimistic")) { + executor.subject.getTaskKey("PessimisticAnswerTask").copyTo(executor.selectedTask); +} +else if (executor.inFields.get("mode").equals("optimistic")) { + executor.subject.getTaskKey("OptimisticAnswerTask").copyTo(executor.selectedTask); +} +else if (executor.inFields.get("mode").equals("dithering")) { + executor.subject.getTaskKey("DitheringAnswerTask").copyTo(executor.selectedTask); +} +//else if (executor.inFields.get("mode").equals("roundrobin")) { +// executor.subject.getTaskKey("RoundRobinAnswerTask").copyTo(executor.selectedTask); +//} + +executor.logger.info("Answer Selected Task:" + executor.selectedTask);
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/OptimisticAnswerTask.js b/examples/examples-decisionmaker/src/main/resources/logic/OptimisticAnswerTask.js new file mode 100644 index 000000000..e197c5f07 --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/OptimisticAnswerTask.js @@ -0,0 +1,37 @@ +/* + * ============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 size = executor.getContextAlbum("AnswerAlbum").size(); + +var selection = size - Math.floor(Math.random() * size / 2) - 1; + +var selectionA = "a" + selection; + +executor.logger.info(size); +executor.logger.info(selectionA); + +executor.outFields.put("decision", executor.getContextAlbum("AnswerAlbum").get(selectionA)); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/PessimisticAnswerTask.js b/examples/examples-decisionmaker/src/main/resources/logic/PessimisticAnswerTask.js new file mode 100644 index 000000000..34942d846 --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/PessimisticAnswerTask.js @@ -0,0 +1,37 @@ +/* + * ============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 size = executor.getContextAlbum("AnswerAlbum").size(); + +var selection = Math.floor(Math.random() * size / 2); + +var selectionA = "a" + selection; + +executor.logger.info(size); +executor.logger.info(selectionA); + +executor.outFields.put("decision", executor.getContextAlbum("AnswerAlbum").get(selectionA)); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/RandomAnswerTask.js b/examples/examples-decisionmaker/src/main/resources/logic/RandomAnswerTask.js new file mode 100644 index 000000000..f4012ac6e --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/RandomAnswerTask.js @@ -0,0 +1,37 @@ +/* + * ============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 size = executor.getContextAlbum("AnswerAlbum").size(); + +var selection = Math.floor(Math.random() * size); + +var selectionA = "a" + selection; + +executor.logger.info(size); +executor.logger.info(selectionA); + +executor.outFields.put("decision", executor.getContextAlbum("AnswerAlbum").get(selectionA)); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/logic/RoundRobinAnswerTask.js b/examples/examples-decisionmaker/src/main/resources/logic/RoundRobinAnswerTask.js new file mode 100644 index 000000000..a3d52f20f --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/logic/RoundRobinAnswerTask.js @@ -0,0 +1,45 @@ +/* + * ============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 size = executor.getContextAlbum("AnswerAlbum").size(); +var lastAnswer = executor.getContextAlbum("LastAnswerAlbum").get("lastAnswer"); + +executor.logger.info(size); +executor.logger.info(lastAnswer); + +var answer = ++lastAnswer; +if (answer >= size) { + answer = 0; +} + +executor.getContextAlbum("LastAnswerAlbum").put("lastAnswer", answer) + +var selectionA = "a" + answer; + +executor.logger.info(selectionA); + +executor.outFields.put("decision", executor.getContextAlbum("AnswerAlbum").get(selectionA)); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex b/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex new file mode 100644 index 000000000..295afa159 --- /dev/null +++ b/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex @@ -0,0 +1,150 @@ +#------------------------------------------------------------------------------- +# ============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========================================================= +#------------------------------------------------------------------------------- + +model create name=DecisionMakerPolicyModel + +schema create name=SimpleStringType flavour=Java schema=java.lang.String +schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer + +album create name=AnswerAlbum scope=policy writable=true schemaName=SimpleStringType +album create name=LastAnswerAlbum scope=policy writable=true schemaName=SimpleIntegerType + +event create name=AnswerEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex +event parameter create name=AnswerEvent parName=a0 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a1 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a2 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a3 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a4 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a5 schemaName=SimpleStringType +event parameter create name=AnswerEvent parName=a6 schemaName=SimpleStringType + +event create name=MakeDecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex +event parameter create name=MakeDecisionEvent parName=mode schemaName=SimpleStringType + +event create name=DecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex +event parameter create name=DecisionEvent parName=decision schemaName=SimpleStringType + +task create name=AnswerInitTask +task inputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType +task inputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType + +task outputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType +task outputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType + +task contextref create name=AnswerInitTask albumName=AnswerAlbum +task contextref create name=AnswerInitTask albumName=LastAnswerAlbum + +task logic create name=AnswerInitTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AnswerInitTask.js" +LE + +task create name=RandomAnswerTask + +task inputfield create name=RandomAnswerTask fieldName=mode schemaName=SimpleStringType + +task outputfield create name=RandomAnswerTask fieldName=decision schemaName=SimpleStringType + +task contextref create name=RandomAnswerTask albumName=AnswerAlbum + +task logic create name=RandomAnswerTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/RandomAnswerTask.js" +LE + +task create name=PessimisticAnswerTask + +task inputfield create name=PessimisticAnswerTask fieldName=mode schemaName=SimpleStringType + +task outputfield create name=PessimisticAnswerTask fieldName=decision schemaName=SimpleStringType + +task contextref create name=PessimisticAnswerTask albumName=AnswerAlbum + +task logic create name=PessimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/PessimisticAnswerTask.js" +LE + +task create name=OptimisticAnswerTask + +task inputfield create name=OptimisticAnswerTask fieldName=mode schemaName=SimpleStringType + +task outputfield create name=OptimisticAnswerTask fieldName=decision schemaName=SimpleStringType + +task contextref create name=OptimisticAnswerTask albumName=AnswerAlbum + +task logic create name=OptimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/OptimisticAnswerTask.js" +LE + +task create name=DitheringAnswerTask + +task inputfield create name=DitheringAnswerTask fieldName=mode schemaName=SimpleStringType + +task outputfield create name=DitheringAnswerTask fieldName=decision schemaName=SimpleStringType + +task contextref create name=DitheringAnswerTask albumName=AnswerAlbum + +task logic create name=DitheringAnswerTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/DitheringAnswerTask.js" +LE + +#task create name=RoundRobinAnswerTask +# +#task inputfield create name=RoundRobinAnswerTask fieldName=mode schemaName=SimpleStringType +# +#task outputfield create name=RoundRobinAnswerTask fieldName=decision schemaName=SimpleStringType +# +#task contextref create name=RoundRobinAnswerTask albumName=AnswerAlbum +#task contextref create name=RoundRobinAnswerTask albumName=LastAnswerAlbum +# +#task logic create name=RoundRobinAnswerTask logicFlavour=JAVASCRIPT logic=LS +##MACROFILE:"src/main/resources/logic/RoundRobinAnswerTask.js" +#LE + +policy create name=AnswerInitPolicy template=freestyle firstState=AnswerInitState + +policy state create name=AnswerInitPolicy stateName=AnswerInitState triggerName=AnswerEvent defaultTaskName=AnswerInitTask +policy state output create name=AnswerInitPolicy stateName=AnswerInitState outputName=AnswerInitOutput eventName=AnswerEvent +policy state taskref create name=AnswerInitPolicy stateName=AnswerInitState taskName=AnswerInitTask outputType=DIRECT outputName=AnswerInitOutput + +policy create name=DecisionMakerPolicy template=freestyle firstState=MakeDecisionState + +policy state create name=DecisionMakerPolicy stateName=MakeDecisionState triggerName=MakeDecisionEvent defaultTaskName=RandomAnswerTask +policy state output create name=DecisionMakerPolicy stateName=MakeDecisionState outputName=DecisionFinalOutput eventName=DecisionEvent +policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=RandomAnswerTask outputType=DIRECT outputName=DecisionFinalOutput +policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=PessimisticAnswerTask outputType=DIRECT outputName=DecisionFinalOutput +policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=OptimisticAnswerTask outputType=DIRECT outputName=DecisionFinalOutput +policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=DitheringAnswerTask outputType=DIRECT outputName=DecisionFinalOutput +#policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=RoundRobinAnswerTask outputType=DIRECT outputName=DecisionFinalOutput + +policy state selecttasklogic create name=DecisionMakerPolicy stateName=MakeDecisionState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/MakeDecisionStateTSL.js" +LE + +validate + diff --git a/examples/examples-onap-vcpe/pom.xml b/examples/examples-onap-vcpe/pom.xml new file mode 100644 index 000000000..2fa531529 --- /dev/null +++ b/examples/examples-onap-vcpe/pom.xml @@ -0,0 +1,85 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 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========================================================= +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.apex-pdp.examples</groupId> + <artifactId>examples</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <artifactId>examples-onap-vcpe</artifactId> + <name>${project.artifactId}</name> + <description>Specific code for the APEX ONAP vCPE Example</description> + + <properties> + <policymodel.name>ONAPvCPEPolicyModel</policymodel.name> + <apex-domains-onap-vcpe-dir>${project.basedir}/src</apex-domains-onap-vcpe-dir> + </properties> + + <dependencies> + <dependency> + <groupId>org.onap.policy.apex-pdp.auth</groupId> + <artifactId>cli-editor</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.policy.apex-pdp.services</groupId> + <artifactId>services-engine</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-grizzly2-http</artifactId> + <version>${version.jersey}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Generate the APEX Policy JSON from the APEX CLI command --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-policy</id> + <phase>compile</phase> + <goals> + <goal>java</goal> + </goals> + <configuration> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <classpathScope>compile</classpathScope> + <arguments> + <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> + <argument>--output-model-file=${project.build.directory}/classes/${policymodel.name}.json</argument> + <argument>--log-file=${project.build.directory}/${policymodel.name}_policygeneration.log</argument> + <argument>--working-dir=${project.basedir}</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js new file mode 100644 index 000000000..f3c0c45cd --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupRequestTask.js @@ -0,0 +1,44 @@ +/* + * ============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 guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper("decisionAttributes").createNewInstance(); + +guardDecisionAttributes.put("actor", "APPC"); +guardDecisionAttributes.put("recipe", "Restart"); +guardDecisionAttributes.put("target", executor.inFields.get("vnfID").toString()); +guardDecisionAttributes.put("clname", "APEXvCPEImplementation"); + +executor.logger.info(guardDecisionAttributes); + +executor.outFields.put("decisionAttributes", guardDecisionAttributes); +executor.outFields.put("onapName", "APEX"); + +executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionID.toString(), + executor.inFields.get("vnfID")); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ 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 new file mode 100644 index 000000000..df98c25f4 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AAILookupResponseTask.js @@ -0,0 +1,50 @@ +/* + * ============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 guardResult = executor.inFields.get("decision"); + +if (guardResult === "PERMIT") { + vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_PERMIT"); +} else if (guardResult === "DENY") { + vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY"); +} else { + executor.message = "guard result must be either \"PERMIT\" or \"DENY\""; + returnValue = executor.FALSE; +} + +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.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js new file mode 100644 index 000000000..45a70c014 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFRequestTask.js @@ -0,0 +1,76 @@ +/* + * ============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 genericDataRecordType = Java.type("org.apache.avro.generic.GenericData.Record"); + +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); + +var appcBodyRecord = executor.subject.getOutFieldSchemaHelper("body").createNewInstance(); +var appcBodyRecordSchema = appcBodyRecord.getSchema(); + +var inputRecord = new genericDataRecordType(appcBodyRecordSchema.getField("input").schema()); +var inputRecordRecordSchema = inputRecord.getSchema(); + +var actionIndentifiersRecord = new genericDataRecordType(inputRecordRecordSchema.getField("action_DasH_identifiers") + .schema()); + +var commonHeaderRecord = new genericDataRecordType(inputRecordRecordSchema.getField("common_DasH_header").schema()); +var commonHeaderRecordSchema = commonHeaderRecord.getSchema(); + +var commonHeaderFlagsRecord = new genericDataRecordType(commonHeaderRecordSchema.getField("flags").schema()); + +appcBodyRecord.put("input", inputRecord); +inputRecord.put("action_DasH_identifiers", actionIndentifiersRecord); +inputRecord.put("common_DasH_header", commonHeaderRecord); +commonHeaderRecord.put("flags", commonHeaderFlagsRecord); + +inputRecord.put("action", "Restart"); +inputRecord.put("payload", "{}"); + +actionIndentifiersRecord.put("vnf_DasH_id", executor.inFields.get("vnfID").toString()); + +commonHeaderRecord.put("timestamp", new Date().toISOString()); +commonHeaderRecord.put("api_DasH_ver", "2.00"); +commonHeaderRecord.put("originator_DasH_id", executor.inFields.get("requestID").toString()); +commonHeaderRecord.put("request_DasH_id", executor.inFields.get("requestID").toString()); +commonHeaderRecord.put("sub_DasH_request_DasH_id", "1"); + +commonHeaderFlagsRecord.put("ttl", "10000"); +commonHeaderFlagsRecord.put("force", "TRUE"); +commonHeaderFlagsRecord.put("mode", "EXCLUSIVE"); + +executor.outFields.put("version", "2.0"); +executor.outFields.put("rpc-name", "restart"); +executor.outFields.put("correlation-id", executor.inFields.get("vnfID")); +executor.outFields.put("type", "request"); +executor.outFields.put("body", appcBodyRecord); + +executor.getContextAlbum("RequestIDVNFIDAlbum").put(executor.inFields.get("requestID").toString(), + executor.inFields.get("vnfID")); + +vcpeClosedLoopStatus.put("notification", "OPERATION: RESTART REQUESTED"); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js new file mode 100644 index 000000000..d382e6274 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/APPCRestartVNFResponseTask.js @@ -0,0 +1,50 @@ +/* + * ============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 uuidType = Java.type("java.util.UUID"); +var integerType = Java.type("java.lang.Integer"); + +var requestID = uuidType.fromString(executor.inFields.get("correlation-id")); +var vnfID = executor.getContextAlbum("RequestIDVNFIDAlbum").remove(requestID.toString()); + +var returnValue = executor.TRUE; + +if (vnfID != null) { + var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID.toString()); + + var notification = "OPERATION: VNF RESTART WITH RETURN CODE " + + executor.inFields.get("body").get("output").get("status").get("code") + ", " + + executor.inFields.get("body").get("output").get("status").get("message"); + + vcpeClosedLoopStatus.put("notification", notification); + vcpeClosedLoopStatus.put("notificationTime", executor.inFields.get("body").get("output").get("common_DasH_header") + .get("timestamp")); + + executor.outFields.put("requestID", requestID); + executor.outFields.put("vnfID", vnfID); +} else { + executor.message = "VNF ID not found in context album for request ID " + requestID; + returnValue = executor.FALSE +} + +executor.logger.info(executor.outFields); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js new file mode 100644 index 000000000..1fb46b7ba --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/AbatedTask.js @@ -0,0 +1,32 @@ +/* + * ============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()); + +vcpeClosedLoopStatus.put("notification", "VCPE NOTIFICATION HAS BEEN ABATED"); +vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString()); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js new file mode 100644 index 000000000..65922e7f1 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/ControlLoopLogTask.js @@ -0,0 +1,48 @@ +/* + * ============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("Logging context information for VNF \"" + executor.inFields.get("vnfID") + "\""); + +executor.outFields.put("AAI", vcpeClosedLoopStatus.get("AAI")); +executor.outFields.put("closedLoopControlName", vcpeClosedLoopStatus.get("closedLoopControlName")); +executor.outFields.put("closedLoopAlarmStart", vcpeClosedLoopStatus.get("closedLoopAlarmStart")); +executor.outFields.put("closedLoopAlarmEnd", vcpeClosedLoopStatus.get("closedLoopAlarmEnd")); +executor.outFields.put("closedLoopEventClient", vcpeClosedLoopStatus.get("closedLoopEventClient")); +executor.outFields.put("closedLoopEventStatus", vcpeClosedLoopStatus.get("closedLoopEventStatus")); +executor.outFields.put("version", vcpeClosedLoopStatus.get("version")); +executor.outFields.put("requestID", vcpeClosedLoopStatus.get("requestID")); +executor.outFields.put("target_type", vcpeClosedLoopStatus.get("target_type")); +executor.outFields.put("target", vcpeClosedLoopStatus.get("target")); +executor.outFields.put("from", vcpeClosedLoopStatus.get("from")); +executor.outFields.put("policyScope", vcpeClosedLoopStatus.get("policyScope")); +executor.outFields.put("policyName", vcpeClosedLoopStatus.get("policyName")); +executor.outFields.put("policyVersion", vcpeClosedLoopStatus.get("policyVersion")); +executor.outFields.put("notification", vcpeClosedLoopStatus.get("notification")); +executor.outFields.put("notificationTime", vcpeClosedLoopStatus.get("notificationTime")); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js new file mode 100644 index 000000000..7f3a9d6b6 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/DeniedTask.js @@ -0,0 +1,32 @@ +/* + * ============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()); + +vcpeClosedLoopStatus.put("notification", "VCPE VNF RESTART HAS BEEN DENIED BY GUARD"); +vcpeClosedLoopStatus.put("notificationTime", new Date().toISOString()); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js new file mode 100644 index 000000000..435d6d735 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GetVCPEStateTask.js @@ -0,0 +1,69 @@ +/* + * ============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 uuidType = Java.type("java.util.UUID"); +var longType = Java.type("java.lang.Long"); + +var requestID = uuidType.fromString(executor.inFields.get("requestID")); +var vnfID = uuidType.fromString(executor.inFields.get("AAI").get("generic_DasH_vnf_DoT_vnf_DasH_id")); + +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get(vnfID); + +if (vcpeClosedLoopStatus == null) { + executor.logger.info("Creating context information for new vCPE VNF \"" + vnfID.toString() + "\""); + + vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").getSchemaHelper().createNewInstance(); + + vcpeClosedLoopStatus.put("AAI", executor.inFields.get("AAI")); + vcpeClosedLoopStatus.put("closedLoopControlName", executor.inFields.get("closedLoopControlName")); + vcpeClosedLoopStatus.put("closedLoopAlarmStart", executor.inFields.get("closedLoopAlarmStart")); + vcpeClosedLoopStatus.put("closedLoopEventClient", executor.inFields.get("closedLoopEventClient")); + vcpeClosedLoopStatus.put("closedLoopEventStatus", executor.inFields.get("closedLoopEventStatus")); + vcpeClosedLoopStatus.put("version", executor.inFields.get("version")); + vcpeClosedLoopStatus.put("requestID", executor.inFields.get("requestID")); + vcpeClosedLoopStatus.put("target_type", executor.inFields.get("target_type")); + vcpeClosedLoopStatus.put("target", executor.inFields.get("target")); + vcpeClosedLoopStatus.put("from", executor.inFields.get("from")); + vcpeClosedLoopStatus.put("policyScope", "vCPE"); + vcpeClosedLoopStatus.put("policyName", "ONAPvCPEPolicyModel"); + vcpeClosedLoopStatus.put("policyVersion", "0.0.1"); + vcpeClosedLoopStatus.put("notification", ""); + vcpeClosedLoopStatus.put("notificationTime", ""); + + if (executor.inFields.get("closedLoopAlarmEnd") != null) { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", executor.inFields.get("closedLoopAlarmEnd")); + } else { + vcpeClosedLoopStatus.put("closedLoopAlarmEnd", longType.valueOf(0)); + } + + executor.getContextAlbum("VCPEClosedLoopStatusAlbum").put(vnfID.toString(), vcpeClosedLoopStatus); + + executor.logger.info("Created context information for new vCPE VNF \"" + vnfID.toString() + "\""); +} + +executor.outFields.put("requestID", requestID); +executor.outFields.put("vnfID", vnfID); + +executor.logger.info(executor.outFields); + +returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js new file mode 100644 index 000000000..f3c0c45cd --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardRequestTask.js @@ -0,0 +1,44 @@ +/* + * ============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 guardDecisionAttributes = executor.subject.getOutFieldSchemaHelper("decisionAttributes").createNewInstance(); + +guardDecisionAttributes.put("actor", "APPC"); +guardDecisionAttributes.put("recipe", "Restart"); +guardDecisionAttributes.put("target", executor.inFields.get("vnfID").toString()); +guardDecisionAttributes.put("clname", "APEXvCPEImplementation"); + +executor.logger.info(guardDecisionAttributes); + +executor.outFields.put("decisionAttributes", guardDecisionAttributes); +executor.outFields.put("onapName", "APEX"); + +executor.getContextAlbum("ControlLoopExecutionIDAlbum").put(executor.executionID.toString(), + executor.inFields.get("vnfID")); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js new file mode 100644 index 000000000..df98c25f4 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/GuardResponseTask.js @@ -0,0 +1,50 @@ +/* + * ============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 guardResult = executor.inFields.get("decision"); + +if (guardResult === "PERMIT") { + vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_PERMIT"); +} else if (guardResult === "DENY") { + vcpeClosedLoopStatus.put("notification", "OPERATION: GUARD_DENY"); +} else { + executor.message = "guard result must be either \"PERMIT\" or \"DENY\""; + returnValue = executor.FALSE; +} + +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.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/NoAAILookupTask.js b/examples/examples-onap-vcpe/src/main/resources/logic/NoAAILookupTask.js new file mode 100644 index 000000000..0c088078f --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/NoAAILookupTask.js @@ -0,0 +1,26 @@ +/* + * ============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); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js new file mode 100644 index 000000000..7bbfcd9ca --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyAAILookupStateTSL.js @@ -0,0 +1,46 @@ +/* + * ============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.TRUE; + +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); +var aaiInfo = vcpeClosedLoopStatus.get("AAI"); + +executor.logger.info(aaiInfo); + +if (aaiInfo.get("generic_DasH_vnf.resource_DasH_version") != null + && aaiInfo.get("generic_DasH_vnf.vnf_DasH_name") != null + && aaiInfo.get("generic_DasH_vnf.prov_DasH_status") != null + && aaiInfo.get("generic_DasH_vnf.is_DasH_closed_DasH_loop_DasH_disabled") != null + && aaiInfo.get("generic_DasH_vnf.orchestration_DasH_status") != null + && aaiInfo.get("generic_DasH_vnf.vnf_DasH_type") != null + && aaiInfo.get("generic_DasH_vnf.in_DasH_maint") != null + && aaiInfo.get("generic_DasH_vnf.service_DasH_id") != null + && aaiInfo.get("generic_DasH_vnf.vnf_DasH_id") != null) { + executor.subject.getTaskKey("AAILookupRequestTask").copyTo(executor.selectedTask); +} else { + executor.subject.getTaskKey("NoAAILookupTask").copyTo(executor.selectedTask); +} + +executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js new file mode 100644 index 000000000..3fea4a025 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js @@ -0,0 +1,43 @@ +/* + * ============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.TRUE; + +var vcpeClosedLoopStatus = executor.getContextAlbum("VCPEClosedLoopStatusAlbum").get( + executor.inFields.get("vnfID").toString()); + +var status = vcpeClosedLoopStatus.get("closedLoopEventStatus"); + +var returnValue = executor.TRUE; + +if (status === "ONSET") { + executor.subject.getTaskKey("GuardRequestTask").copyTo(executor.selectedTask); +} else if (status === "ABATED") { + executor.subject.getTaskKey("AbatedTask").copyTo(executor.selectedTask); + onsetFlag = executor.FALSE; +} else { + executor.message = "closedLoopEventStatus must be either \"ONSET\" or \"ABATED\""; + returnValue = executor.FALSE; +} + +executor.logger.info("ReceiveEventPolicyOnsetOrAbatedStateTSL State Selected Task:" + executor.selectedTask); diff --git a/examples/examples-onap-vcpe/src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js b/examples/examples-onap-vcpe/src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js new file mode 100644 index 000000000..b1b6420cb --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js @@ -0,0 +1,37 @@ +/* + * ============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 guardResult = vcpeClosedLoopStatus.get("notification"); + +if (guardResult === "OPERATION: GUARD_PERMIT") { + executor.subject.getTaskKey("APPCRestartVNFRequestTask").copyTo(executor.selectedTask); +} else { + executor.subject.getTaskKey("DeniedTask").copyTo(executor.selectedTask); +} + +executor.logger.info("RestartAPPCRequestPolicyPermitOrDenyTSL State Selected Task:" + executor.selectedTask); + +var returnValue = executor.TRUE; diff --git a/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex new file mode 100644 index 000000000..22d0ddae0 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/policy/ONAPvCPEPolicyModel.apex @@ -0,0 +1,320 @@ +#------------------------------------------------------------------------------- +# ============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========================================================= +#------------------------------------------------------------------------------- + +model create name=ONAPvCPEPolicyModel + +schema create name=SimpleStringType flavour=Java schema=java.lang.String +schema create name=SimpleLongType flavour=Java schema=java.lang.Long +schema create name=SimpleBooleanType flavour=Java schema=java.lang.Boolean +schema create name=UUIDType flavour=Java schema=java.util.UUID + +schema create name=VCPEAAIInfoType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/VCPEAAIInfoType.avsc" +LE + +schema create name=GuardDecisionAttributesType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/GuardDecisionAttributesType.avsc" +LE + +schema create name=APPCInputBodyType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/APPCInputBodyType.avsc" +LE + +schema create name=APPCOutputBodyType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/APPCOutputBodyType.avsc" +LE + +schema create name=VCPEClosedLoopStatusType flavour=Avro schema=LS +#MACROFILE:"src/main/resources/schemas/VCPEClosedLoopStatusType.avsc" +LE + +album create name=VCPEClosedLoopStatusAlbum scope=policy writable=true schemaName=VCPEClosedLoopStatusType + +album create name=ControlLoopExecutionIDAlbum scope=policy writable=true schemaName=UUIDType + +album create name=RequestIDVNFIDAlbum scope=policy writable=true schemaName=UUIDType + +event create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 version=1.0.2 nameSpace=org.onap.policy.apex.onap.vcpe source=DCAE target=APEX + +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopControlName schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopAlarmStart schemaName=SimpleLongType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopEventClient schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=closedLoopEventStatus schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=requestID schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=target_type schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=target schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=from schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=version schemaName=SimpleStringType +event parameter create name=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 parName=AAI schemaName=VCPEAAIInfoType + +event create name=VCPEStateUpdatedEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX + +event parameter create name=VCPEStateUpdatedEvent parName=requestID schemaName=UUIDType +event parameter create name=VCPEStateUpdatedEvent parName=vnfID schemaName=UUIDType + +event create name=GuardRequestEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX + +event parameter create name=GuardRequestEvent parName=decisionAttributes schemaName=GuardDecisionAttributesType +event parameter create name=GuardRequestEvent parName=onapName schemaName=SimpleStringType + +event create name=GuardResponseEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX + +event parameter create name=GuardResponseEvent parName=decision schemaName=SimpleStringType +event parameter create name=GuardResponseEvent parName=details schemaName=SimpleStringType + +event create name=APPCRestartVNFRequestEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC + +event parameter create name=APPCRestartVNFRequestEvent parName=body schemaName=APPCInputBodyType +event parameter create name=APPCRestartVNFRequestEvent parName=version schemaName=SimpleStringType +event parameter create name=APPCRestartVNFRequestEvent parName=rpc-name schemaName=SimpleStringType +event parameter create name=APPCRestartVNFRequestEvent parName=correlation-id schemaName=SimpleStringType +event parameter create name=APPCRestartVNFRequestEvent parName=type schemaName=SimpleStringType + +event create name=APPCRestartVNFResponseEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APPC + +event parameter create name=APPCRestartVNFResponseEvent parName=body schemaName=APPCOutputBodyType +event parameter create name=APPCRestartVNFResponseEvent parName=version schemaName=SimpleStringType +event parameter create name=APPCRestartVNFResponseEvent parName=rpc-name schemaName=SimpleStringType +event parameter create name=APPCRestartVNFResponseEvent parName=correlation-id schemaName=SimpleStringType +event parameter create name=APPCRestartVNFResponseEvent parName=type schemaName=SimpleStringType + +event create name=ControlLoopLogEvent nameSpace=org.onap.policy.apex.onap.vcpe source=APEX target=APEX + +event parameter create name=ControlLoopLogEvent parName=AAI schemaName=VCPEAAIInfoType +event parameter create name=ControlLoopLogEvent parName=closedLoopControlName schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=closedLoopAlarmStart schemaName=SimpleLongType +event parameter create name=ControlLoopLogEvent parName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true +event parameter create name=ControlLoopLogEvent parName=closedLoopEventClient schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=closedLoopEventStatus schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=version schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=requestID schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=target_type schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=target schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=from schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=policyScope schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=policyName schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=policyVersion schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=notification schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=message schemaName=SimpleStringType +event parameter create name=ControlLoopLogEvent parName=notificationTime schemaName=SimpleStringType + +task create name=GetVCPEStateTask + +task inputfield create name=GetVCPEStateTask fieldName=closedLoopControlName schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=closedLoopAlarmStart schemaName=SimpleLongType +task inputfield create name=GetVCPEStateTask fieldName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true +task inputfield create name=GetVCPEStateTask fieldName=closedLoopEventClient schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=closedLoopEventStatus schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=requestID schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=target_type schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=target schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=from schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=version schemaName=SimpleStringType +task inputfield create name=GetVCPEStateTask fieldName=AAI schemaName=VCPEAAIInfoType + +task contextref create name=GetVCPEStateTask albumName=VCPEClosedLoopStatusAlbum + +task outputfield create name=GetVCPEStateTask fieldName=requestID schemaName=UUIDType +task outputfield create name=GetVCPEStateTask fieldName=vnfID schemaName=UUIDType + +task logic create name=GetVCPEStateTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/GetVCPEStateTask.js" +LE + +task create name=AbatedTask + +task inputfield create name=AbatedTask fieldName=requestID schemaName=UUIDType +task inputfield create name=AbatedTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=AbatedTask fieldName=requestID schemaName=UUIDType +task outputfield create name=AbatedTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=AbatedTask albumName=VCPEClosedLoopStatusAlbum + +task logic create name=AbatedTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/AbatedTask.js" +LE + +task create name=GuardRequestTask + +task inputfield create name=GuardRequestTask fieldName=requestID schemaName=UUIDType +task inputfield create name=GuardRequestTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=GuardRequestTask fieldName=decisionAttributes schemaName=GuardDecisionAttributesType +task outputfield create name=GuardRequestTask fieldName=onapName schemaName=SimpleStringType + +task contextref create name=GuardRequestTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=GuardRequestTask albumName=ControlLoopExecutionIDAlbum + +task logic create name=GuardRequestTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/GuardRequestTask.js" +LE + +task create name=GuardResponseTask + +task inputfield create name=GuardResponseTask fieldName=decision schemaName=SimpleStringType +task inputfield create name=GuardResponseTask fieldName=details schemaName=SimpleStringType + +task outputfield create name=GuardResponseTask fieldName=requestID schemaName=UUIDType +task outputfield create name=GuardResponseTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=GuardResponseTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=GuardResponseTask albumName=ControlLoopExecutionIDAlbum + +task logic create name=GuardResponseTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/GuardResponseTask.js" +LE + +task create name=DeniedTask + +task inputfield create name=DeniedTask fieldName=requestID schemaName=UUIDType +task inputfield create name=DeniedTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=DeniedTask fieldName=requestID schemaName=UUIDType +task outputfield create name=DeniedTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=DeniedTask albumName=VCPEClosedLoopStatusAlbum + +task logic create name=DeniedTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/DeniedTask.js" +LE + +task create name=APPCRestartVNFRequestTask + +task inputfield create name=APPCRestartVNFRequestTask fieldName=requestID schemaName=UUIDType +task inputfield create name=APPCRestartVNFRequestTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=APPCRestartVNFRequestTask fieldName=body schemaName=APPCInputBodyType +task outputfield create name=APPCRestartVNFRequestTask fieldName=version schemaName=SimpleStringType +task outputfield create name=APPCRestartVNFRequestTask fieldName=rpc-name schemaName=SimpleStringType +task outputfield create name=APPCRestartVNFRequestTask fieldName=correlation-id schemaName=SimpleStringType +task outputfield create name=APPCRestartVNFRequestTask fieldName=type schemaName=SimpleStringType + +task contextref create name=APPCRestartVNFRequestTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=APPCRestartVNFRequestTask albumName=RequestIDVNFIDAlbum + +task logic create name=APPCRestartVNFRequestTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/APPCRestartVNFRequestTask.js" +LE + +task create name=APPCRestartVNFResponseTask + +task inputfield create name=APPCRestartVNFResponseTask fieldName=body schemaName=APPCOutputBodyType +task inputfield create name=APPCRestartVNFResponseTask fieldName=version schemaName=SimpleStringType +task inputfield create name=APPCRestartVNFResponseTask fieldName=rpc-name schemaName=SimpleStringType +task inputfield create name=APPCRestartVNFResponseTask fieldName=correlation-id schemaName=SimpleStringType +task inputfield create name=APPCRestartVNFResponseTask fieldName=type schemaName=SimpleStringType + +task outputfield create name=APPCRestartVNFResponseTask fieldName=requestID schemaName=UUIDType +task outputfield create name=APPCRestartVNFResponseTask fieldName=vnfID schemaName=UUIDType + +task contextref create name=APPCRestartVNFResponseTask albumName=VCPEClosedLoopStatusAlbum +task contextref create name=APPCRestartVNFResponseTask albumName=RequestIDVNFIDAlbum + +task logic create name=APPCRestartVNFResponseTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/APPCRestartVNFResponseTask.js" +LE + +task create name=ControlLoopLogTask + +task inputfield create name=ControlLoopLogTask fieldName=requestID schemaName=UUIDType +task inputfield create name=ControlLoopLogTask fieldName=vnfID schemaName=UUIDType + +task outputfield create name=ControlLoopLogTask fieldName=AAI schemaName=VCPEAAIInfoType +task outputfield create name=ControlLoopLogTask fieldName=closedLoopControlName schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=closedLoopAlarmStart schemaName=SimpleLongType +task outputfield create name=ControlLoopLogTask fieldName=closedLoopAlarmEnd schemaName=SimpleLongType optional=true +task outputfield create name=ControlLoopLogTask fieldName=closedLoopEventClient schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=closedLoopEventStatus schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=requestID schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=version schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=target_type schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=target schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=from schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=policyScope schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=policyName schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=policyVersion schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=notification schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=message schemaName=SimpleStringType +task outputfield create name=ControlLoopLogTask fieldName=notificationTime schemaName=SimpleStringType + +task contextref create name=ControlLoopLogTask albumName=VCPEClosedLoopStatusAlbum + +task logic create name=ControlLoopLogTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ControlLoopLogTask.js" +LE + +policy create name=ReceiveEventPolicy template=Freestyle firstState=GetVCPEState + +policy state create name=ReceiveEventPolicy stateName=AbatedState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=ReceiveEventPolicy stateName=AbatedState outputName=AbatedOutput eventName=ControlLoopLogEvent +policy state taskref create name=ReceiveEventPolicy stateName=AbatedState taskName=ControlLoopLogTask outputType=DIRECT outputName=AbatedOutput + +policy state create name=ReceiveEventPolicy stateName=OnsetOrAbatedState triggerName=VCPEStateUpdatedEvent defaultTaskName=AbatedTask +policy state output create name=ReceiveEventPolicy stateName=OnsetOrAbatedState outputName=OnsetOutput eventName=GuardRequestEvent +policy state taskref create name=ReceiveEventPolicy stateName=OnsetOrAbatedState taskName=GuardRequestTask outputType=DIRECT outputName=OnsetOutput +policy state output create name=ReceiveEventPolicy stateName=OnsetOrAbatedState outputName=AbatedOutput eventName=VCPEStateUpdatedEvent nextState=AbatedState +policy state taskref create name=ReceiveEventPolicy stateName=OnsetOrAbatedState taskName=AbatedTask outputType=DIRECT outputName=AbatedOutput + +policy state contextref create name=ReceiveEventPolicy stateName=OnsetOrAbatedState albumName=VCPEClosedLoopStatusAlbum + +policy state selecttasklogic create name=ReceiveEventPolicy stateName=OnsetOrAbatedState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/ReceiveEventPolicyOnsetOrAbatedStateTSL.js" +LE + +policy state create name=ReceiveEventPolicy stateName=GetVCPEState triggerName=ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1 defaultTaskName=GetVCPEStateTask +policy state output create name=ReceiveEventPolicy stateName=GetVCPEState outputName=GetVCPEStateOutput eventName=VCPEStateUpdatedEvent nextState=OnsetOrAbatedState +policy state taskref create name=ReceiveEventPolicy stateName=GetVCPEState taskName=GetVCPEStateTask outputType=DIRECT outputName=GetVCPEStateOutput + +policy create name=RestartAPPCRequestPolicy template=Freestyle firstState=PolicyGuardResponseState + +policy state create name=RestartAPPCRequestPolicy stateName=DeniedState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=RestartAPPCRequestPolicy stateName=DeniedState outputName=DeniedOutput eventName=ControlLoopLogEvent +policy state taskref create name=RestartAPPCRequestPolicy stateName=DeniedState taskName=ControlLoopLogTask outputType=DIRECT outputName=DeniedOutput + +policy state create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState triggerName=VCPEStateUpdatedEvent defaultTaskName=DeniedTask +policy state output create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState outputName=PermitOutput eventName=APPCRestartVNFRequestEvent +policy state taskref create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState taskName=APPCRestartVNFRequestTask outputType=DIRECT outputName=PermitOutput +policy state output create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState outputName=DenyOutput eventName=VCPEStateUpdatedEvent nextState=DeniedState +policy state taskref create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState taskName=DeniedTask outputType=DIRECT outputName=DenyOutput + +policy state create name=RestartAPPCRequestPolicy stateName=PolicyGuardResponseState triggerName=GuardResponseEvent defaultTaskName=GuardResponseTask +policy state output create name=RestartAPPCRequestPolicy stateName=PolicyGuardResponseState outputName=GuardResponseOutput eventName=VCPEStateUpdatedEvent nextState=PermitOrDenyState +policy state taskref create name=RestartAPPCRequestPolicy stateName=PolicyGuardResponseState taskName=GuardResponseTask outputType=DIRECT outputName=GuardResponseOutput + +policy state contextref create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState albumName=VCPEClosedLoopStatusAlbum + +policy state selecttasklogic create name=RestartAPPCRequestPolicy stateName=PermitOrDenyState logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/RestartAPPCRequestPolicyPermitOrDenyTSL.js" +LE + +policy create name=RestartAPPCResponsePolicy template=Freestyle firstState=RestartAPPCResponseState + +policy state create name=RestartAPPCResponsePolicy stateName=ResponseLogState triggerName=VCPEStateUpdatedEvent defaultTaskName=ControlLoopLogTask +policy state output create name=RestartAPPCResponsePolicy stateName=ResponseLogState outputName=ResponseLogOutput eventName=ControlLoopLogEvent +policy state taskref create name=RestartAPPCResponsePolicy stateName=ResponseLogState taskName=ControlLoopLogTask outputType=DIRECT outputName=ResponseLogOutput + +policy state create name=RestartAPPCResponsePolicy stateName=RestartAPPCResponseState triggerName=APPCRestartVNFResponseEvent defaultTaskName=APPCRestartVNFResponseTask +policy state output create name=RestartAPPCResponsePolicy stateName=RestartAPPCResponseState outputName=APPCRestartVNFResponseOutput eventName=VCPEStateUpdatedEvent nextState=ResponseLogState +policy state taskref create name=RestartAPPCResponsePolicy stateName=RestartAPPCResponseState taskName=APPCRestartVNFResponseTask outputType=DIRECT outputName=APPCRestartVNFResponseOutput + +validate + diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc new file mode 100644 index 000000000..621372d2f --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInstanceFiltersType.avsc @@ -0,0 +1,30 @@ +{ + "type": "record", + "name": "AAIInstanceFilters_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "type": "record", + "name": "instance_DasH_filters", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "instance_DasH_filter", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "generic_DasH_vnf", + "fields": [ + { + "name": "vnf_DasH_id", + "type": "string" + } + ] + } + } + } + ] + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc new file mode 100644 index 000000000..e64d0e36a --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/AAIInventoryResponseItemType.avsc @@ -0,0 +1,70 @@ +{ + "type": "array", + "items": { + "type": "record", + "name": "AAIInventoryResponseItem_Type", + "fields": [ + { + "name": "model_DasH_name", + "type": "string" + }, + { + "name": "extra_DasH_properties", + "type": { + "type": "record", + "name": "AAIInventoryResponseItemExtraProperties_Type", + "fields": [] + } + }, + { + "name": "generic_DasH_vnf", + "type": { + "type": "record", + "name": "AAIInventoryResponseItemGenericVNF_Type", + "fields": [ + { + "name": "vnf_DasH_id", + "type": "string" + }, + { + "name": "vnf_DasH_name", + "type": "string" + }, + { + "name": "vnf_DasH_type", + "type": "string" + }, + { + "name": "service_DasH_id", + "type": "string" + }, + { + "name": "orchestration_DasH_status", + "type": "string" + }, + { + "name": "in_DasH_maint", + "type": "boolean" + }, + { + "name": "is_DasH_closed_DasH_loop_DasH_disabled", + "type": "boolean" + }, + { + "name": "resource_DasH_version", + "type": "string" + }, + { + "name": "model_DasH_invariant_DasH_id", + "type": "string" + }, + { + "name": "model_DasH_version_DasH_id", + "type": "string" + } + ] + } + } + ] + } +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc new file mode 100644 index 000000000..ffa3ca534 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/AAINamedQueryType.avsc @@ -0,0 +1,11 @@ +{ + "type": "record", + "name": "AAINamedQuery_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "named_DasH_query_DasH_uuid", + "type": "string" + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc new file mode 100644 index 000000000..3acf96e7f --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCInputBodyType.avsc @@ -0,0 +1,76 @@ +{ + "type" : "record", + "name" : "APPCInputBody_Type", + "namespace" : "org.onap.policy.apex.onap.vcpe", + "fields" : [ + { + "name": "input", + "type": { + "type" : "record", + "name" : "InputRecord", + "fields" : [ + { + "name": "action", "type": "string" + }, + { + "name": "action_DasH_identifiers", + "type": { + "type" : "record", + "name" : "ActionIdentifiersRecord", + "fields" : [ + { + "name": "vnf_DasH_id", "type": "string" + } + ] + } + }, + { + "name": "common_DasH_header", + "type": { + "type" : "record", + "name" : "InputCommonHeaderRecord", + "fields" : [ + { + "name": "request_DasH_id", "type": "string" + }, + { + "name": "originator_DasH_id", "type": "string" + }, + { + "name": "api_DasH_ver", "type": "string" + }, + { + "name": "sub_DasH_request_DasH_id", "type": "string" + }, + { + "name": "timestamp", "type": "string" + }, + { + "name": "flags", + "type": { + "type" : "record", + "name" : "FlagsRecord", + "fields" : [ + { + "name": "ttl", "type": "string" + }, + { + "name": "force", "type": "string" + }, + { + "name": "mode", "type": "string" + } + ] + } + } + ] + } + }, + { + "name": "payload", "type": "string" + } + ] + } + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc new file mode 100644 index 000000000..2c110170a --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/APPCOutputBodyType.avsc @@ -0,0 +1,55 @@ +{ + "type" : "record", + "name" : "APPCOutputBody_Type", + "namespace" : "org.onap.policy.apex.onap.vcpe", + "fields" : [ + { + "name": "output", + "type": { + "type" : "record", + "name" : "OutputRecord", + "fields" : [ + { + "name": "status", + "type": { + "type" : "record", + "name" : "StatusRecord", + "fields" : [ + { + "name": "code", "type": "int" + }, + { + "name": "message", "type": "string" + } + ] + } + }, + { + "name": "common_DasH_header", + "type": { + "type" : "record", + "name" : "OutputCommonHeaderRecord", + "fields" : [ + { + "name": "request_DasH_id", "type": "string" + }, + { + "name": "originator_DasH_id", "type": "string" + }, + { + "name": "api_DasH_ver", "type": "string" + }, + { + "name": "sub_DasH_request_DasH_id", "type": "string" + }, + { + "name": "timestamp", "type": "string" + } + ] + } + } + ] + } + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/GuardDecisionAttributesType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/GuardDecisionAttributesType.avsc new file mode 100644 index 000000000..bc25955fa --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/GuardDecisionAttributesType.avsc @@ -0,0 +1,23 @@ +{ + "type": "record", + "name": "GuardDecisionAttributes_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "actor", + "type": "string" + }, + { + "name": "recipe", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "clname", + "type": "string" + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc new file mode 100644 index 000000000..ff7cad18a --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEAAIInfoType.avsc @@ -0,0 +1,43 @@ +{ + "type": "record", + "name": "AAI_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "generic_DasH_vnf_DoT_resource_DasH_version", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_name", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_prov_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_type", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_in_DasH_maint", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_service_DasH_id", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_id", + "type": "string" + } + ] +} diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc new file mode 100644 index 000000000..e628c23d9 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusType.avsc @@ -0,0 +1,112 @@ +{ + "type": "record", + "name": "VCPEClosedLoopStatus", + "fields": [ + { + "name": "AAI", + "type": { + "type": "record", + "name": "VCPE_AAI_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "generic_DasH_vnf_DoT_resource_DasH_version", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_name", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_prov_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_type", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_in_DasH_maint", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_service_DasH_id", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_id", + "type": "string" + } + ] + } + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopAlarmEnd", + "type": "long" + }, + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "requestID", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "closedLoopEventStatus", + "type": "string" + }, + { + "name": "target_type", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "notification", + "type": "string" + }, + { + "name": "notificationTime", + "type": "string" + } + ] +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc new file mode 100644 index 000000000..9b76f9440 --- /dev/null +++ b/examples/examples-onap-vcpe/src/main/resources/schemas/VCPEClosedLoopStatusTypeWithHistory.avsc @@ -0,0 +1,152 @@ +{ + "type": "record", + "name": "VCPEClosedLoopStatus", + "fields": [ + { + "name": "AAI", + "type": { + "type": "record", + "name": "VCPE_AAI_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "generic_DasH_vnf_DoT_resource_DasH_version", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_name", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_prov_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_type", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_in_DasH_maint", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_service_DasH_id", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_id", + "type": "string" + } + ] + } + }, + { + "name": "closedLoopAlarmStart", + "type": "long" + }, + { + "name": "closedLoopControlName", + "type": "string" + }, + { + "name": "version", + "type": "string" + }, + { + "name": "requestID", + "type": "string" + }, + { + "name": "closedLoopEventClient", + "type": "string" + }, + { + "name": "closedLoopEventStatus", + "type": "string" + }, + { + "name": "target_type", + "type": "string" + }, + { + "name": "target", + "type": "string" + }, + { + "name": "from", + "type": "string" + }, + { + "name": "policyScope", + "type": "string" + }, + { + "name": "policyName", + "type": "string" + }, + { + "name": "policyVersion", + "type": "string" + }, + { + "name": "notification", + "type": "string" + }, + { + "name": "history", + "type": [ + { + "type": "record", + "name": "VCPE_History_Type", + "namespace": "org.onap.policy.apex.onap.vcpe", + "fields": [ + { + "name": "generic_DasH_vnf_DoT_resource_DasH_version", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_name", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_prov_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_is_DasH_closed_DasH_loop_DasH_disabled", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_orchestration_DasH_status", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_type", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_in_DasH_maint", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_service_DasH_id", + "type": "string" + }, + { + "name": "generic_DasH_vnf_DoT_vnf_DasH_id", + "type": "string" + } + ] + } + ] + } + ] +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSim.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSim.java new file mode 100644 index 000000000..a821462f6 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSim.java @@ -0,0 +1,59 @@ +/*- + * ============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========================================================= + */ + +package org.onap.policy.apex.domains.onap.vcpe; + +import java.net.URI; + +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.server.ResourceConfig; +import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; + +public class AAIAndGuardSim { + private static final String BASE_URI = "http://192.168.144.235:54321/AAIAndGuardSim"; + private HttpServer server; + + public AAIAndGuardSim() { + final ResourceConfig rc = new ResourceConfig(AAIAndGuardSimEndpoint.class); + server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); + + while (!server.isStarted()) { + ThreadUtilities.sleep(50); + } + } + + public void tearDown() throws Exception { + server.shutdown(); + } + + public static void main(final String[] args) throws Exception { + final AAIAndGuardSim sim = new AAIAndGuardSim(); + + while (true) { + try { + Thread.sleep(100); + } catch (final InterruptedException e) { + break; + } + } + sim.tearDown(); + } +} diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSimEndpoint.java new file mode 100644 index 000000000..6c7f7db19 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/AAIAndGuardSimEndpoint.java @@ -0,0 +1,137 @@ +/*- + * ============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========================================================= + */ + +package org.onap.policy.apex.domains.onap.vcpe; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.gson.Gson; + +import java.util.Map; +import java.util.Random; + +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; + + +@Path("/sim") +public class AAIAndGuardSimEndpoint { + + private static int postMessagesReceived = 0; + private static int putMessagesReceived = 0; + private static int statMessagesReceived = 0; + private static int getMessagesReceived = 0; + + @Path("/pdp/api/Stats") + @GET + public Response serviceGetStats() { + statMessagesReceived++; + return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } + + @Path("/pdp/api/getDecision") + @POST + public Response serviceGuardPostRequest(final String jsonString) { + postMessagesReceived++; + + if (postMessagesReceived % 2 == 0) { + return Response.status(200).entity("{\"decision\": \"PERMIT\", \"details\": \"Decision Permit. OK!\"}") + .build(); + } else { + return Response.status(200).entity("{\"decision\": \"DENY\", \"details\": \"Decision Denied. NOK :-(\"}") + .build(); + } + } + + @Path("/event/GetEvent") + @GET + public Response serviceGetEvent() { + final Random rand = new Random(); + final int nextMatchCase = rand.nextInt(4); + final String nextEventName = "Event0" + rand.nextInt(2) + "00"; + + final String eventString = "{\n" + "\"nameSpace\": \"org.onap.policy.apex.sample.events\",\n" + "\"name\": \"" + + nextEventName + "\",\n" + "\"version\": \"0.0.1\",\n" + "\"source\": \"REST_" + getMessagesReceived + + "\",\n" + "\"target\": \"apex\",\n" + "\"TestSlogan\": \"Test slogan for External Event0\",\n" + + "\"TestMatchCase\": " + nextMatchCase + ",\n" + "\"TestTimestamp\": " + System.currentTimeMillis() + + ",\n" + "\"TestTemperature\": 9080.866\n" + "}"; + + getMessagesReceived++; + + return Response.status(200).entity(eventString).build(); + } + + @Path("/event/GetEmptyEvent") + @GET + public Response serviceGetEmptyEvent() { + return Response.status(200).build(); + } + + @Path("/event/GetEventBadResponse") + @GET + public Response serviceGetEventBadResponse() { + return Response.status(400).build(); + } + + @Path("/event/PostEvent") + @POST + public Response servicePostRequest(final String jsonString) { + postMessagesReceived++; + + @SuppressWarnings("unchecked") + final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); + assertTrue(jsonMap.containsKey("name")); + assertEquals("0.0.1", jsonMap.get("version")); + assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); + assertEquals("Act", jsonMap.get("source")); + assertEquals("Outside", jsonMap.get("target")); + + return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } + + @Path("/event/PostEventBadResponse") + @POST + public Response servicePostRequestBadResponse(final String jsonString) { + return Response.status(400).build(); + } + + @Path("/event/PutEvent") + @PUT + public Response servicePutRequest(final String jsonString) { + putMessagesReceived++; + + @SuppressWarnings("unchecked") + final Map<String, Object> jsonMap = new Gson().fromJson(jsonString, Map.class); + assertTrue(jsonMap.containsKey("name")); + assertEquals("0.0.1", jsonMap.get("version")); + assertEquals("org.onap.policy.apex.sample.events", jsonMap.get("nameSpace")); + assertEquals("Act", jsonMap.get("source")); + assertEquals("Outside", jsonMap.get("target")); + + return Response.status(200).entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + "}").build(); + } +} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json b/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json new file mode 100644 index 000000000..f2ffdf079 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/config/ApexConfigFileOnly.json @@ -0,0 +1,88 @@ +{ + "engineServiceParameters": { + "name": "MyApexEngine", + "version": "0.0.1", + "id": 45, + "instanceCount": 4, + "deploymentPort": 12561, + "policyModelFileName": "policy/ONAPTLGoalPolicyModel.json", + "engineParameters": { + "executorParameters": { + "JAVASCRIPT": { + "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters" + } + }, + "contextParameters": { + "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters", + "schemaParameters": { + "Avro": { + "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters" + } + } + } + } + }, + "eventInputParameters": { + "VCPEInitConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "src/main/resources/config/VCPEInitiationEvents.txt" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON", + "parameters": { + "nameAlias": "closedLoopControlName", + "versionAlias": "version", + "sourceAlias": "from" + } + } + }, + "GuardRequestorConsumer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters", + "parameters": { + "url": "http://localhost:54321/AAIAndGuardSim/sim/pdp/api/getDecision", + "httpMethod": "POST", + "restRequestTimeout": 2000 + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventName": "GuardResponseEvent", + "eventNameFilter": "GuardResponseEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorProducer", + "requestorTimeout": 500 + } + }, + "eventOutputParameters": { + "GuardRequestorProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "RESTREQUESTOR", + "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restrequestor.RESTRequestorCarrierTechnologyParameters" + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + }, + "eventNameFilter": "GuardRequestEvent", + "requestorMode": true, + "requestorPeer": "GuardRequestorConsumer", + "requestorTimeout": 500 + }, + "logProducer": { + "carrierTechnologyParameters": { + "carrierTechnology": "FILE", + "parameters": { + "fileName": "/tmp/VCPEEventsOut.json" + } + }, + "eventProtocolParameters": { + "eventProtocol": "JSON" + } + } + } +} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json b/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json new file mode 100644 index 000000000..2d2005d98 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/config/appc.lcm.success.json @@ -0,0 +1,22 @@ +{ + "body": { + "output": { + "common-header": { + "timestamp": "2017-08-25T21:06:23.037Z", + "api-ver": "5.00", + "originator-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "sub-request-id": "1", + "flags": {} + }, + "status": { + "code": 400, + "message": "Restart Successful" + } + } + }, + "version": "2.0", + "rpc-name": "restart", + "correlation-id": "664be3d2-6c12-4f4b-a3e7-c349acced200-1", + "type": "response" +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json new file mode 100644 index 000000000..729451191 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.abatement.json @@ -0,0 +1,16 @@ +{ + "closedLoopControlName": "${closedLoopControlName}", + "closedLoopAlarmStart": 1463679805324, + "closedLoopAlarmEnd": 1463699805324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json new file mode 100644 index 000000000..feb15c153 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/config/dcae.vcpe.onset.json @@ -0,0 +1,15 @@ +{ + "closedLoopControlName": "${closedLoopControlName}", + "closedLoopAlarmStart": 1463679805324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIQuery.json b/examples/examples-onap-vcpe/src/test/resources/events/AAIQuery.json new file mode 100644 index 000000000..46b5dbe73 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/AAIQuery.json @@ -0,0 +1,16 @@ +{ + "query-parameters": { + "named-query": { + "named-query-uuid": "a93ac487-409c-4e8c-9e5f-334ae8f99087" + } + }, + "instance-filters": { + "instance-filter": [ + { + "generic-vnf": { + "vnf-id": "de7cc3ab-0212-47df-9e64-da1c79234deb" + } + } + ] + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4Policy.json b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4Policy.json new file mode 100644 index 000000000..5bcff1b4b --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4Policy.json @@ -0,0 +1,76 @@ +{ + "inventory-response-item": [ + { + "model-name": "service-instance", + "generic-vnf": { + "vnf-id": "de7cc3ab-0212-47df-9e64-da1c79234deb", + "vnf-name": "ZRDM2MMEX39", + "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "orchestration-status": "active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1503082370097", + "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4", + "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "service-instance", + "service-instance": { + "service-instance-id": "37b8cdb7-94eb-468f-a0c2-4e3c3546578e", + "service-instance-name": "Changed Service Instance NAME", + "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4", + "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9", + "resource-version": "1503082993532", + "orchestration-status": "Active" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "pnf", + "generic-vnf": { + "vnf-id": "jimmy-test", + "vnf-name": "jimmy-test-vnf", + "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "orchestration-status": "active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1504013830207", + "model-invariant-id": "862b25a1-262a-4961-bdaa-cdc55d69785a", + "model-version-id": "e9f1fa7d-c839-418a-9601-03dc0d2ad687" + }, + "extra-properties": { + } + }, + { + "model-name": "service-instance", + "generic-vnf": { + "vnf-id": "jimmy-test-vnf2", + "vnf-name": "jimmy-test-vnf2-named", + "vnf-type": "vMME Svc Jul 14/vMME VF Jul 14 1", + "service-id": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "orchestration-status": "active", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1504014833841", + "model-invariant-id": "82194af1-3c2c-485a-8f44-420e22a9eaa4", + "model-version-id": "46b92144-923a-4d20-b85a-3cbd847668a9" + }, + "extra-properties": { + } + } + ] + } + } + ] + } + } + ] +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4VNF.json b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4VNF.json new file mode 100644 index 000000000..3e8391eaa --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponse4VNF.json @@ -0,0 +1,287 @@ +{ + "inventory-response-item": [ + { + "model-name": "vFW", + "generic-vnf": { + "vnf-id": "vFirewall_demo_app", + "vnf-name": "vFirewall_demo_app", + "vnf-type": "vFW", + "service-id": "vFirewall_demo_app", + "orchestration-status": "running", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509456799110", + "model-invariant-id": "vFirewall", + "model-version-id": "vFW" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "vserver": { + "vserver-id": "5b06cf36-40a0-4bcb-bde9-849aa4702d67", + "vserver-name": "vFW", + "vserver-name2": "vFW", + "prov-status": "Running", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/466979b815b5415ba14ada713e6e1846/servers/5b06cf36-40a0-4bcb-bde9-849aa4702d67", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509047869791" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "vnfc": { + "vnfc-name": "VNFC_vGMUX_demo_app2", + "nfc-naming-code": "vGMUXCODE2", + "nfc-function": "vGMUX", + "prov-status": "Running", + "orchestration-status": "Error", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509407048855" + }, + "extra-properties": { + } + }, + { + "tenant": { + "tenant-id": "466979b815b5415ba14ada713e6e1846", + "tenant-name": "Integration", + "resource-version": "1508920100541" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "pod25", + "cloud-region-id": "RegionOne", + "identity-url": "http://10.12.25.2:5000/v3", + "sriov-automation": false, + "resource-version": "1509048416263" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "esr-system-info": { + "esr-system-info-id": "432ac032-e996-41f2-84ed-9c7a1766eb29", + "system-name": "example-system-name-val-29070", + "type": "example-type-val-85254", + "vendor": "example-vendor-val-94515", + "version": "example-version-val-71880", + "service-url": "http://10.12.25.2:5000/v3", + "user-name": "demo", + "password": "onapdemo", + "system-type": "VIM", + "ssl-cacert": "example-ssl-cacert-val-75021", + "ssl-insecure": true, + "ip-address": "example-ip-address-val-44431", + "port": "example-port-val-93234", + "cloud-domain": "Default", + "default-tenant": "Integration", + "resource-version": "1508920101033" + }, + "extra-properties": { + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "vserver": { + "vserver-id": "0c52905c-f682-42cf-bd52-e7f8953e80e3", + "vserver-name": "vFW", + "vserver-name2": "vFW", + "prov-status": "Running", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/466979b815b5415ba14ada713e6e1846/servers/0c52905c-f682-42cf-bd52-e7f8953e80e3", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509047548567" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "vnfc": { + "vnfc-name": "VNFC_vGMUX_demo_app3", + "nfc-naming-code": "vGMUXCODE3", + "nfc-function": "vGMUX", + "prov-status": "Running", + "orchestration-status": "Running", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509041912808" + }, + "extra-properties": { + } + }, + { + "tenant": { + "tenant-id": "466979b815b5415ba14ada713e6e1846", + "tenant-name": "Integration", + "resource-version": "1508920100541" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "pod25", + "cloud-region-id": "RegionOne", + "identity-url": "http://10.12.25.2:5000/v3", + "sriov-automation": false, + "resource-version": "1509048416263" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "esr-system-info": { + "esr-system-info-id": "432ac032-e996-41f2-84ed-9c7a1766eb29", + "system-name": "example-system-name-val-29070", + "type": "example-type-val-85254", + "vendor": "example-vendor-val-94515", + "version": "example-version-val-71880", + "service-url": "http://10.12.25.2:5000/v3", + "user-name": "demo", + "password": "onapdemo", + "system-type": "VIM", + "ssl-cacert": "example-ssl-cacert-val-75021", + "ssl-insecure": true, + "ip-address": "example-ip-address-val-44431", + "port": "example-port-val-93234", + "cloud-domain": "Default", + "default-tenant": "Integration", + "resource-version": "1508920101033" + }, + "extra-properties": { + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "vserver": { + "vserver-id": "33e16e02-098a-4f4e-a37f-b4e0307596c0", + "vserver-name": "vFW", + "vserver-name2": "vFW", + "prov-status": "Running", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/466979b815b5415ba14ada713e6e1846/servers/33e16e02-098a-4f4e-a37f-b4e0307596c0", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509047285114" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "vnfc": { + "vnfc-name": "vnfc-related-to-vserver-example", + "nfc-naming-code": "example-nfc-naming-code-val-78172", + "nfc-function": "example-nfc-function-val-56352", + "prov-status": "example-prov-status-val-10699", + "orchestration-status": "example-orchestration-status-val-68896", + "ipaddress-v4-oam-vip": "example-ipaddress-v4-oam-vip-val-71483", + "in-maint": true, + "is-closed-loop-disabled": true, + "group-notation": "example-group-notation-val-31912", + "resource-version": "1508800709772" + }, + "extra-properties": { + } + }, + { + "vnfc": { + "vnfc-name": "VNFC_vGMUX_demo_app", + "nfc-naming-code": "vGMUXCODE", + "nfc-function": "vGMUX", + "prov-status": "Running", + "orchestration-status": "Running", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1509041573965" + }, + "extra-properties": { + } + }, + { + "tenant": { + "tenant-id": "466979b815b5415ba14ada713e6e1846", + "tenant-name": "Integration", + "resource-version": "1508920100541" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "pod25", + "cloud-region-id": "RegionOne", + "identity-url": "http://10.12.25.2:5000/v3", + "sriov-automation": false, + "resource-version": "1509048416263" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "esr-system-info": { + "esr-system-info-id": "432ac032-e996-41f2-84ed-9c7a1766eb29", + "system-name": "example-system-name-val-29070", + "type": "example-type-val-85254", + "vendor": "example-vendor-val-94515", + "version": "example-version-val-71880", + "service-url": "http://10.12.25.2:5000/v3", + "user-name": "demo", + "password": "onapdemo", + "system-type": "VIM", + "ssl-cacert": "example-ssl-cacert-val-75021", + "ssl-insecure": true, + "ip-address": "example-ip-address-val-44431", + "port": "example-port-val-93234", + "cloud-domain": "Default", + "default-tenant": "Integration", + "resource-version": "1508920101033" + }, + "extra-properties": { + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } + } + ] +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/AAIResponseExample.json b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponseExample.json new file mode 100644 index 000000000..1d3f64c78 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/AAIResponseExample.json @@ -0,0 +1,206 @@ +{ + "inventory-response-item": [ + { + "vserver": { + "vserver-id": "6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", + "vserver-name": "zdfw1lb01lb02", + "vserver-name2": "zdfw1lb01lb02", + "prov-status": "ACTIVE", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/41d6d38489bd40b09ea8a6b6b852dcbd/servers/6ed3642c-f7a1-4a7c-9290-3d51fe1531eb", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1510606403522" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vLoadBalancer", + "generic-vnf": { + "vnf-id": "db373a8d-f7be-4d02-8ac8-6ca4c305d144", + "vnf-name": "Vfmodule_vLB1113", + "vnf-type": "vLoadBalancer-1106/vLoadBalancer 0", + "service-id": "66f157fc-4148-4880-95f5-e120677e98d1", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1510604011851", + "model-invariant-id": "cee050ed-92a5-494f-ab04-234307a846dc", + "model-version-id": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2", + "model-customization-id": "1983c783-444f-4e79-af3a-85e5d49628f3", + "nf-type": "", + "nf-function": "", + "nf-role": "", + "nf-naming-code": "" + }, + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "fd65becc-6b2c-4fe8-ace9-cc29db9a3da2" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancer" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "cee050ed-92a5-494f-ab04-234307a846dc" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vLoadBalancer-1106", + "service-instance": { + "service-instance-id": "3b12f31f-8f2d-4f5c-b875-61ff1194b941", + "service-instance-name": "vLoadBalancer-1113", + "model-invariant-id": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a", + "model-version-id": "732d4692-4b97-46f9-a996-0b3339e88c50", + "resource-version": "1510603936425" + }, + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "732d4692-4b97-46f9-a996-0b3339e88c50" + }, + { + "property-name": "model-ver.model-name", + "property-value": "vLoadBalancer-1106" + }, + { + "property-name": "model.model-type", + "property-value": "service" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "1321d60d-f7ff-4300-96c2-6bf0b3268b7a" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1.0" + } + ] + } + }, + { + "model-name": "Vloadbalancer..base_vlb..module-0", + "vf-module": { + "vf-module-id": "e6b3e3eb-34e1-4c00-b8c1-2a4fbe479b12", + "vf-module-name": "Vfmodule_vLB1113-1", + "heat-stack-id": "Vfmodule_vLB1113-1/3dd6d900-772f-4fcc-a0cb-e250ab2bb4db", + "orchestration-status": "active", + "is-base-vf-module": true, + "resource-version": "1510604612557", + "model-invariant-id": "6d760188-9a24-451a-b05b-e08b86cb94f2", + "model-version-id": "93facad9-55f2-4fe0-9574-814c2bc2d071", + "model-customization-id": "93fd5bd4-8051-4074-8530-c0c504604df5", + "module-index": 0 + }, + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "93facad9-55f2-4fe0-9574-814c2bc2d071" + }, + { + "property-name": "model-ver.model-name", + "property-value": "Vloadbalancer..base_vlb..module-0" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "6d760188-9a24-451a-b05b-e08b86cb94f2" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1" + } + ] + } + }, + { + "model-name": "Vloadbalancer..dnsscaling..module-1", + "vf-module": { + "vf-module-id": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", + "vf-module-name": "dummy_db373a8d-f7be-4d02-8ac8-6ca4c305d144", + "is-base-vf-module": false, + "resource-version": "1510610079687", + "model-invariant-id": "356a1cff-71f2-4086-9980-a2927ce11c1c", + "model-version-id": "6b93d804-cfc8-4be3-92cc-9336d135859a" + }, + "extra-properties": { + "extra-property": [ + { + "property-name": "model-ver.model-version-id", + "property-value": "6b93d804-cfc8-4be3-92cc-9336d135859a" + }, + { + "property-name": "model-ver.model-name", + "property-value": "Vloadbalancer..dnsscaling..module-1" + }, + { + "property-name": "model.model-type", + "property-value": "resource" + }, + { + "property-name": "model.model-invariant-id", + "property-value": "356a1cff-71f2-4086-9980-a2927ce11c1c" + }, + { + "property-name": "model-ver.model-version", + "property-value": "1" + } + ] + } + } + ] + } + }, + { + "tenant": { + "tenant-id": "41d6d38489bd40b09ea8a6b6b852dcbd", + "tenant-name": "Integration-SB-00", + "resource-version": "1509587770200" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "cloud-region": { + "cloud-owner": "CloudOwner", + "cloud-region-id": "RegionOne", + "cloud-type": "SharedNode", + "owner-defined-type": "OwnerType", + "cloud-region-version": "v1", + "cloud-zone": "CloudZone", + "sriov-automation": false, + "resource-version": "1509587770092" + }, + "extra-properties": { + } + } + ] + } + } + ] + } + } + ] +} diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartRequestEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartRequestEvent.json new file mode 100644 index 000000000..6e18a91b0 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartRequestEvent.json @@ -0,0 +1,22 @@ +{ + "rpc-name": "restart", + "version": "2.0", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "request", + "body": { + "input": { + "common-header": { + "timestamp": "2018-02-26T10:23:41.97Z", + "api-ver": "2.15", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": {} + }, + "action": "Restart", + "action-identifiers": { + "vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1" + } + } + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseNOKEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseNOKEvent.json new file mode 100644 index 000000000..9a0ff9af1 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseNOKEvent.json @@ -0,0 +1,22 @@ +{ + "rpc-name": "restart", + "version": "0.0.1", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "response", + "body": { + "output": { + "common-header": { + "timestamp": "2018-02-26T10:23:42.97Z", + "api-ver": "5.00", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": {} + }, + "status": { + "code": 400, + "message": "Restart Failed" + } + } + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKEvent.json new file mode 100644 index 000000000..4afc51d85 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKEvent.json @@ -0,0 +1,22 @@ +{ + "rpc-name": "restart", + "version": "0.0.1", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "type": "response", + "body": { + "output": { + "common-header": { + "timestamp": "2018-02-26T10:23:42.97Z", + "api-ver": "5.00", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "request-id": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "sub-request-id": "1", + "flags": {} + }, + "status": { + "code": 200, + "message": "Restart Successful" + } + } + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKInitialEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKInitialEvent.json new file mode 100644 index 000000000..2f53a83bc --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/APPCvCPERestartResponseOKInitialEvent.json @@ -0,0 +1,22 @@ +{ + "rpc-name": "restart", + "version": "0.0.1", + "correlation-id": "4a68f8a5-0db9-4070-a132-adede51ebeef", + "type": "response", + "body": { + "output": { + "common-header": { + "timestamp": "2018-02-26T10:23:42.97Z", + "api-ver": "5.00", + "originator-id": "4a68f8a5-0db9-4070-a132-adede51ebeef", + "request-id": "4a68f8a5-0db9-4070-a132-adede51ebeef", + "sub-request-id": "1", + "flags": {} + }, + "status": { + "code": 200, + "message": "Restart Successful" + } + } + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedAAIInfoEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedAAIInfoEvent.json new file mode 100644 index 000000000..5efbfef69 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedAAIInfoEvent.json @@ -0,0 +1,23 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638001326, + "closedLoopAlarmEnd": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1", + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF13", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "cCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f" + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedNoAAIInfoEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedNoAAIInfoEvent.json new file mode 100644 index 000000000..7cc910e96 --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/VCPEAbatedNoAAIInfoEvent.json @@ -0,0 +1,15 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638001326, + "closedLoopAlarmEnd": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ABATED", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "version": "1.0.2", + "from": "DCAE", + "AAI": { + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1" + } +}
\ No newline at end of file diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetAAIInfoEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetAAIInfoEvent.json new file mode 100644 index 000000000..405cc0b2b --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetAAIInfoEvent.json @@ -0,0 +1,22 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-85317438-861d-42a9-979e-9d96dc0a9ef1", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "4a68f8a5-0db9-4070-a132-adede51e3d5c", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "generic-vnf.resource-version": "1", + "generic-vnf.vnf-name": "vCPEInfraVNF13", + "generic-vnf.prov-status": "PREPROV", + "generic-vnf.is-closed-loop-disabled": "false", + "generic-vnf.orchestration-status": "Created", + "generic-vnf.vnf-type": "cCPEInfraService10/vCPEInfraService10 0", + "generic-vnf.in-maint": "false", + "generic-vnf.service-id": "5585fd2c-ad0d-4050-b0cf-dfe4a03bd01f", + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetNoAAIInfoEvent.json b/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetNoAAIInfoEvent.json new file mode 100644 index 000000000..342451a0c --- /dev/null +++ b/examples/examples-onap-vcpe/src/test/resources/events/VCPEOnsetNoAAIInfoEvent.json @@ -0,0 +1,15 @@ +{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "closedLoopAlarmStart": 1519638197324, + "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca", + "closedLoopEventStatus": "ONSET", + "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200", + "target_type": "VNF", + "target": "generic-vnf.vnf-id", + "AAI": { + "vserver.is-closed-loop-disabled": "false", + "generic-vnf.vnf-id": "b4fe00ac-1da6-4b00-ac0d-8e8300db39e1" + }, + "from": "DCAE", + "version": "1.0.2" +} diff --git a/examples/examples-periodic/pom.xml b/examples/examples-periodic/pom.xml new file mode 100644 index 000000000..ed0e5b19f --- /dev/null +++ b/examples/examples-periodic/pom.xml @@ -0,0 +1,74 @@ +<!-- + ============LICENSE_START======================================================= + Copyright (C) 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========================================================= +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.policy.apex-pdp.examples</groupId> + <artifactId>examples</artifactId> + <version>2.0.0-SNAPSHOT</version> + </parent> + + <artifactId>examples-periodic</artifactId> + <name>${project.artifactId}</name> + <description>APEX periodic event example</description> + + <properties> + <policymodel.name>PeriodicPolicyModel</policymodel.name> + <apex-domains-periodic-dir>${project.basedir}/src</apex-domains-periodic-dir> + </properties> + + <dependencies> + <dependency> + <groupId>org.onap.policy.apex-pdp.auth</groupId> + <artifactId>cli-editor</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <!-- Generate the APEX Policy JSON from the APEX CLI command --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-policy</id> + <phase>compile</phase> + <goals> + <goal>java</goal> + </goals> + <configuration> + <mainClass>org.onap.policy.apex.auth.clieditor.ApexCLIEditorMain</mainClass> + <classpathScope>compile</classpathScope> + <arguments> + <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.name}.apex</argument> + <argument>--output-model-file=${project.build.directory}/classes/${policymodel.name}.json</argument> + <argument>--log-file=${project.build.directory}/${policymodel.name}_policygeneration.log</argument> + <argument>--working-dir=${project.basedir}</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
\ No newline at end of file diff --git a/examples/examples-periodic/src/main/resources/logic/OutputTask.js b/examples/examples-periodic/src/main/resources/logic/OutputTask.js new file mode 100644 index 000000000..0e44653c1 --- /dev/null +++ b/examples/examples-periodic/src/main/resources/logic/OutputTask.js @@ -0,0 +1,26 @@ +/* + * ============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); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-periodic/src/main/resources/logic/PeriodicTask.js b/examples/examples-periodic/src/main/resources/logic/PeriodicTask.js new file mode 100644 index 000000000..18dbcda0e --- /dev/null +++ b/examples/examples-periodic/src/main/resources/logic/PeriodicTask.js @@ -0,0 +1,44 @@ +/* + * ============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 eventList = executor.subject.getOutFieldSchemaHelper("EventList").createNewInstance(); + +var eventType = Java.type("org.onap.policy.apex.service.engine.event.ApexEvent"); + +for (i = 0; i < 5; i++) { + var event = new eventType("InputEvent", "0.0.1", "org.onap.policy.apex.periodic", "APEX", "APEX"); + + var par0 = "Hello: " + i; + var par1 = "Goodbye: " + i; + + event.put("Par0", par0); + event.put("Par1", par1); + + eventList.add(event); +} + +executor.outFields.put("EventList", eventList); + +executor.logger.info(executor.outFields); + +var returnValue = executor.TRUE;
\ No newline at end of file diff --git a/examples/examples-periodic/src/main/resources/policy/PeriodicPolicyModel.apex b/examples/examples-periodic/src/main/resources/policy/PeriodicPolicyModel.apex new file mode 100644 index 000000000..22a07f5f5 --- /dev/null +++ b/examples/examples-periodic/src/main/resources/policy/PeriodicPolicyModel.apex @@ -0,0 +1,83 @@ +#------------------------------------------------------------------------------- +# ============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========================================================= +#------------------------------------------------------------------------------- + +model create name=PeriodicPolicyModel + +schema create name=SimpleLongType flavour=Java schema=java.lang.Long +schema create name=SimpleStringType flavour=Java schema=java.lang.String +schema create name=EventListType flavour=Java schema=org.onap.policy.apex.service.engine.event.ApexEventList + +event create name=PERIODIC_EVENT nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX +event parameter create name=PERIODIC_EVENT parName=PERIODIC_DELAY schemaName=SimpleLongType +event parameter create name=PERIODIC_EVENT parName=PERIODIC_FIRST_TIME schemaName=SimpleLongType +event parameter create name=PERIODIC_EVENT parName=PERIODIC_LAST_TIME schemaName=SimpleLongType +event parameter create name=PERIODIC_EVENT parName=PERIODIC_CURRENT_TIME schemaName=SimpleLongType +event parameter create name=PERIODIC_EVENT parName=PERIODIC_EVENT_COUNT schemaName=SimpleLongType + +event create name=EventListEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX +event parameter create name=EventListEvent parName=EventList schemaName=EventListType + +event create name=InputEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX +event parameter create name=InputEvent parName=Par0 schemaName=SimpleStringType +event parameter create name=InputEvent parName=Par1 schemaName=SimpleStringType + +event create name=OutputEvent nameSpace=org.onap.policy.apex.periodic source=APEX target=APEX +event parameter create name=OutputEvent parName=Par0 schemaName=SimpleStringType +event parameter create name=OutputEvent parName=Par1 schemaName=SimpleStringType + +task create name=PeriodicTask +task inputfield create name=PeriodicTask fieldName=PERIODIC_DELAY schemaName=SimpleLongType +task inputfield create name=PeriodicTask fieldName=PERIODIC_FIRST_TIME schemaName=SimpleLongType +task inputfield create name=PeriodicTask fieldName=PERIODIC_LAST_TIME schemaName=SimpleLongType +task inputfield create name=PeriodicTask fieldName=PERIODIC_CURRENT_TIME schemaName=SimpleLongType +task inputfield create name=PeriodicTask fieldName=PERIODIC_EVENT_COUNT schemaName=SimpleLongType + +task outputfield create name=PeriodicTask fieldName=EventList schemaName=EventListType + +task logic create name=PeriodicTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/PeriodicTask.js" +LE + +task create name=OutputTask +task inputfield create name=OutputTask fieldName=Par0 schemaName=SimpleStringType +task inputfield create name=OutputTask fieldName=Par1 schemaName=SimpleStringType + +task outputfield create name=OutputTask fieldName=Par0 schemaName=SimpleStringType +task outputfield create name=OutputTask fieldName=Par1 schemaName=SimpleStringType + +task logic create name=OutputTask logicFlavour=JAVASCRIPT logic=LS +#MACROFILE:"src/main/resources/logic/OutputTask.js" +LE + +policy create name=PeriodicPolicy template=freestyle firstState=PeriodicState + +policy state create name=PeriodicPolicy stateName=PeriodicState triggerName=PERIODIC_EVENT defaultTaskName=PeriodicTask +policy state output create name=PeriodicPolicy stateName=PeriodicState outputName=PeriodicOutput eventName=EventListEvent +policy state taskref create name=PeriodicPolicy stateName=PeriodicState taskName=PeriodicTask outputType=DIRECT outputName=PeriodicOutput + + +policy create name=OutputPolicy template=freestyle firstState=OutputState + +policy state create name=OutputPolicy stateName=OutputState triggerName=InputEvent defaultTaskName=OutputTask +policy state output create name=OutputPolicy stateName=OutputState outputName=OutputOutput eventName=OutputEvent +policy state taskref create name=OutputPolicy stateName=OutputState taskName=OutputTask outputType=DIRECT outputName=OutputOutput + +validate + diff --git a/examples/pom.xml b/examples/pom.xml index 3d0f969d9..d31c9ff4e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -39,5 +39,8 @@ <module>aadm</module> <module>adaptive</module> <module>pcvs</module> + <module>examples-decisionmaker</module> + <module>examples-periodic</module> + <module>examples-onap-vcpe</module> </modules> </project>
\ No newline at end of file |