[DCAE] Adapt DCAE blueprints to CFY DCAE K8S plugin version 3.x.x
[dcaegen2/platform/blueprints.git] / blueprints / k8s-holmes-rules.yaml
1 # -*- indent-tabs-mode: nil -*- # vi: set expandtab:
2 #
3 # ============LICENSE_START====================================================
4 # =============================================================================
5 # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
6 # =============================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=====================================================
19
20 tosca_definitions_version: cloudify_dsl_1_3
21 imports:
22 - https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml
23 - plugin:k8splugin?version=3.3.0
24 - plugin:dcaepolicyplugin?version=2.4.0
25 - plugin:pgaas?version=1.3.0
26 inputs:
27   msb_hostname:
28     type: string
29     default: "msb-iag.onap"
30   pgaas_cluster_name:
31     type: string
32     default: "dcae-pg-primary.onap"
33     # use the single-VM PG instance
34     #default: pgvm
35   database_name:
36     type: string
37     default: "holmes"
38   hr_image:
39     type: string
40     default: "nexus3.onap.org:10001/onap/holmes/rule-management:1.2.7"
41   service_component_type:
42     type: string
43     default: "holmes-rule-mgmt"
44   service_id:
45     type: string
46     default: "holmes-rule-mgmt"
47 node_templates:
48   pgaasvm:
49     type: dcae.nodes.pgaas.database
50     properties:
51       #writerfqdn: { concat: [ { get_input: pgaas_cluster_name }, '-write.' ] }
52       writerfqdn: { get_input: pgaas_cluster_name }
53       name: { get_input: database_name }
54   holmesrules:
55     type: dcae.nodes.ContainerizedServiceComponent
56     interfaces:
57       cloudify.interfaces.lifecycle:
58         start:
59           inputs:
60            envs:
61             URL_JDBC:
62                 { get_attribute: [ pgaasvm, admin, host ] }
63             JDBC_PASSWORD:
64                 { get_attribute: [ pgaasvm, admin, password ] }
65             JDBC_USERNAME:
66                 { get_attribute: [ pgaasvm, admin, user ] }
67             MSB_ADDR:
68                 get_input: msb_hostname
69            ports:
70              - '9101:0'
71              - '9104:0'
72     properties:
73       service_component_type: { get_input: service_component_type }
74       service_id: { get_input: service_id }
75       application_config:
76         holmes.default.rule.volte.scenario1: "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b$$$package org.onap.holmes.droolsRule;\n\nimport org.onap.holmes.common.dmaap.DmaapService;\nimport org.onap.holmes.common.api.stat.VesAlarm;\nimport org.onap.holmes.common.aai.CorrelationUtil;\nimport org.onap.holmes.common.dmaap.entity.PolicyMsg;\nimport org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;\nimport org.onap.holmes.common.utils.DroolsLog;\n \n\nrule \"Relation_analysis_Rule\"\nsalience 200\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0,\n            $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\n\t\t\t$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),\n\t\t\t$startEpochMicrosec: startEpochMicrosec,\n            eventName in (\"Fault_MultiCloud_VMFailure\"),\n            $eventId: eventId)\n        $child : VesAlarm( eventId != $eventId, parentId == null,\n            CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),\n            eventName in (\"Fault_MME_eNodeB out of service alarm\"),\n            startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )\n    then\n\t\tDroolsLog.printInfo(\"===========================================================\");\n\t\tDroolsLog.printInfo(\"Relation_analysis_Rule: rootId=\" + $root.getEventId() + \", childId=\" + $child.getEventId());\n\t\t$child.setParentId($root.getEventId());\n\t\tupdate($child);\n\t\t\nend\n\nrule \"root_has_child_handle_Rule\"\nsalience 150\nno-loop true\n\twhen\n\t\t$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)\n\t\t$child : VesAlarm(eventId != $eventId, parentId == $eventId)\n\tthen\n\t\tDroolsLog.printInfo(\"===========================================================\");\n\t\tDroolsLog.printInfo(\"root_has_child_handle_Rule: rootId=\" + $root.getEventId() + \", childId=\" + $child.getEventId());\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_no_child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,\n            sourceId != null && !sourceId.equals(\"\"),\n\t\t\tsourceName != null && !sourceName.equals(\"\"),\n            eventName in (\"Fault_MultiCloud_VMFailure\"))\n    then\n\t\tDroolsLog.printInfo(\"===========================================================\");\n\t\tDroolsLog.printInfo(\"root_no_child_handle_Rule: rootId=\" + $root.getEventId());\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_cleared_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)\n    then\n\t\tDroolsLog.printInfo(\"===========================================================\");\n\t\tDroolsLog.printInfo(\"root_cleared_handle_Rule: rootId=\" + $root.getEventId());\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\tretract($root);\nend\n\nrule \"child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)\n    then\n\t\tDroolsLog.printInfo(\"===========================================================\");\n\t\tDroolsLog.printInfo(\"child_handle_Rule: childId=\" + $child.getEventId());\n\t\tretract($child);\nend"
77         msb.hostname:
78          get_input: msb_hostname
79         msb.uri: /api/microservices/v1/services
80         services_calls: {}
81         streams_publishes: {}
82         streams_subscribes: {}
83       image: { get_input: hr_image }
84       #service_component_type: dcae-analytics-holmes-rule-management
85     relationships:
86     - type: cloudify.relationships.depends_on
87       target: pgaasvm