62376ad8d37aa0efb2ecd4e2b11d02cf71303632
[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.4.2
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.9"
41   service_component_type:
42     type: string
43     default: "holmes-rule-mgmt"
44   service_id:
45     type: string
46     default: "holmes-rule-mgmt"
47   service_component_name_override:
48     type: string
49     default: "holmes-rule-mgmt"
50   dcae-analytics-holmes-rule-mgt_cpu_limit:
51     type: string
52     default: "250m"
53   dcae-analytics-holmes-rule-mgt_cpu_request:
54     type: string
55     default: "250m"
56   dcae-analytics-holmes-rule-mgt_memory_limit:
57     type: string
58     default: "1024Mi"
59   dcae-analytics-holmes-rule-mgt_memory_request:
60     type: string
61     default: "256Mi"
62 node_templates:
63   pgaasvm:
64     type: dcae.nodes.pgaas.database
65     properties:
66       #writerfqdn: { concat: [ { get_input: pgaas_cluster_name }, '-write.' ] }
67       writerfqdn: { get_input: pgaas_cluster_name }
68       name: { get_input: database_name }
69   holmesrules:
70     type: dcae.nodes.ContainerizedServiceComponent
71     interfaces:
72       cloudify.interfaces.lifecycle:
73         start:
74           inputs:
75            envs:
76             URL_JDBC:
77                 { get_attribute: [ pgaasvm, admin, host ] }
78             JDBC_PASSWORD:
79                 { get_attribute: [ pgaasvm, admin, password ] }
80             JDBC_USERNAME:
81                 { get_attribute: [ pgaasvm, admin, user ] }
82             MSB_ADDR:
83                 get_input: msb_hostname
84            ports:
85              - '9101:0'
86              - '9104:0'
87     properties:
88       service_component_type: { get_input: service_component_type }
89       service_id: { get_input: service_id }
90       service_component_name_override: { get_input: service_component_name_override }
91       application_config:
92         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, \"dcae_cl_out\");\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, \"dcae_cl_out\");\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, \"dcae_cl_out\");\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"
93         msb.hostname:
94          get_input: msb_hostname
95         msb.uri: /api/microservices/v1/services
96         services_calls: {}
97         streams_publishes: {}
98         streams_subscribes: {}
99       image: { get_input: hr_image }
100       #service_component_type: dcae-analytics-holmes-rule-management
101       resource_config:
102         limits:
103           cpu:
104             get_input: dcae-analytics-holmes-rule-mgt_cpu_limit
105           memory:
106             get_input: dcae-analytics-holmes-rule-mgt_memory_limit
107         requests:
108           cpu:
109             get_input: dcae-analytics-holmes-rule-mgt_cpu_request
110           memory:
111             get_input: dcae-analytics-holmes-rule-mgt_memory_request
112     relationships:
113     - type: cloudify.relationships.depends_on
114       target: pgaasvm