Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kafka producer settings were added #80

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29644,9 +29644,12 @@ suites:
- recipe[oracle_java8::default]
- recipe[opennms::default]
- recipe[onms_lwrp_test::webopts]
- recipe[opennms::kafka_producer]
attributes:
opennms:
version: 26.2.2-1
karaf:
addl_features: ['opennms-kafka-producer' ]
verifier:
inspec_tests:
- path: test/integration/default
Expand Down
8 changes: 8 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2123,3 +2123,11 @@

default['opennms']['bin']['cookbook'] = 'opennms'
default['opennms']['bin']['return_code'] = false

#Kafka
default['opennms']['karaf']['addl_features'] = []
default['opennms']['kafka']['producer'] = {'eventTopic' => 'events', 'alarmTopic' => 'alarms', 'alarmFeedbackTopic' => 'alarmFeedback', 'nodeTopic' => 'nodes', 'topologyVertexTopic' => 'vertices',
'topologyEdgeTopic' => 'edges', 'metricTopic' => 'metrics', 'eventFilter' => '', 'alarmFilter' => '', 'forward.metrics' => false,
'nodeRefreshTimeoutMs' => 300000, 'alarmSyncIntervalMs' => 300000, 'suppressIncrementalAlarms' => true, 'kafkaSendQueueCapacity' => 1000,
'startAlarmSyncWithCleanState' => false}
default['opennms']['kafka']['producer_client'] = {'bootstrap.servers' => '127.0.0.1:9092'}
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
source_url 'https://github.com/dschlenk/opennms-cookbook'
supports 'centos', '>= 6.0'
supports 'redhat', '>= 6.0'
version '28.0.0'
version '28.1.0'
depends 'hostsfile'
depends 'build-essential'
depends 'postgresql'
Expand Down
52 changes: 52 additions & 0 deletions recipes/kafka_producer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true
#
# Cookbook Name:: opennms-cookbook
# Recipe:: kafka_producer
#
# Copyright 2015-2022, ConvergeOne
#
# 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.
#
mv = Opennms::Helpers.major(node['opennms']['version'])
template_dir = if node['opennms']['conf']['cookbook'] == 'opennms'
"horizon-#{format(mv, version: node['opennms']['version'])}/"
else
''
end

template "#{node['opennms']['conf']['home']}/etc/org.opennms.features.kafka.producer.cfg" do
source "#{template_dir}org.opennms.features.kafka.producer.cfg.erb"
owner 'root'
group 'root'
mode 00664
only_if { mv.to_i == 26}
notifies :restart, 'service[opennms]', :delayed
end

template "#{node['opennms']['conf']['home']}/etc/org.opennms.features.kafka.producer.client.cfg" do
source "#{template_dir}org.opennms.features.kafka.producer.client.cfg.erb"
owner 'root'
group 'root'
mode 00664
only_if { mv.to_i == 26}
notifies :restart, 'service[opennms]', :delayed
end

template "#{node['opennms']['conf']['home']}/etc/org.apache.karaf.features.cfg" do
source "#{template_dir}org.apache.karaf.features.cfg.erb"
owner 'root'
group 'root'
mode 00664
only_if { mv.to_i == 26}
notifies :restart, 'service[opennms]', :delayed
end
206 changes: 206 additions & 0 deletions templates/default/horizon-26/org.apache.karaf.features.cfg.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
################################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
################################################################################

#
# Comma separated list of features repositories to register by default
#
#featuresRepositories = \
# mvn:org.apache.karaf.features/spring/4.2.6/xml/features, \
# mvn:org.apache.karaf.features/standard/4.2.6/xml/features, \
# mvn:org.apache.karaf.features/framework/4.2.6/xml/features, \
# mvn:org.apache.karaf.features/enterprise/4.2.6/xml/features

# OPENNMS: Override Karaf's standard-4.2.6-features.xml with our customized version with the HTTP bridge code
# and override Karaf's spring-4.2.6-features.xml and spring-legacy-4.2.6-features.xml with our versions
# that point to the modified standard features.
# OPENNMS: Include the main product features file generated by the mvn:org.opennms.karaf/opennms project
featuresRepositories = \
mvn:org.opennms.karaf/opennms/26.2.2/xml/standard, \
mvn:org.opennms.karaf/opennms/26.2.2/xml/spring, \
mvn:org.opennms.karaf/opennms/26.2.2/xml/spring-legacy, \
mvn:org.apache.karaf.features/framework/4.2.6/xml/features, \
mvn:org.opennms.karaf/opennms/26.2.2/xml/features, \
mvn:org.opennms.karaf/opennms/26.2.2/xml/karaf-extensions
#
# Comma separated list of features to install at startup
#
#featuresBoot = \
# instance, \
# package, \
# log, \
# ssh, \
# framework, \
# system, \
# eventadmin, \
# feature, \
# shell, \
# management, \
# service, \
# jaas, \
# deployer, \
# diagnostic, \
# wrap, \
# bundle, \
# config, \
# kar

# OPENNMS: Parenthetize standard Karaf boot features, add OpenNMS product features
featuresBoot = ( \
instance, \
package, \
log, \
ssh, \
aries-blueprint, \
framework, \
system, \
eventadmin, \
feature, \
shell, \
management, \
service, \
jaas, \
shell-compat, \
deployer, \
diagnostic, \
wrap, \
bundle, \
config, \
kar \
), \
http,\
http-whiteboard,\
opennms-jaas-login-module,\
karaf-extender, \
opennms-osgi-core-rest, \
opennms-health-rest,\
datachoices, \
opennms-activemq-shell, \
opennms-collection-commands, \
opennms-core-ipc-rpc-commands, \
opennms-core-ipc-kafka-shell, \
opennms-dhcpd, \
opennms-events-commands, \
opennms-send-event-command, \
opennms-identity, \
opennms-icmp-commands, \
opennms-snmp-commands, \
opennms-telemetry-collection,\
opennms-telemetry-bmp,\
opennms-telemetry-jti,\
opennms-telemetry-nxos,\
opennms-telemetry-graphite,\
opennms-telemetry-openconfig, \
opennms-dnsresolver-shell,\
opennms-dnsresolver-netty,\
opennms-flows,\
opennms-topology-runtime-browsers,\
opennms-topology-runtime-linkd,\
opennms-topology-runtime-vmware,\
opennms-topology-runtime-application,\
opennms-topology-runtime-bsm,\
opennms-topology-runtime-pathoutage,\
opennms-provisioning-shell,\
opennms-poller-shell,\
opennms-topology-runtime-graphml,\
opennms-topology-runtime-asset,\
opennms-api-layer,\
opennms-blobstore-postgres,\
opennms-jsonstore-shell,\
opennms-threshold-states-shell,\
opennms-measurements-shell,\
opennms-graphml,\
opennms-graphs,\
osgi-nrtg-local,\
vaadin-node-maps,\
vaadin-snmp-events-and-metrics, \
vaadin-dashboard, \
dashlet-summary, \
dashlet-alarms, \
dashlet-bsm, \
dashlet-map, \
dashlet-image, \
dashlet-charts, \
dashlet-grafana, \
dashlet-rtc, \
dashlet-rrd, \
dashlet-ksc, \
dashlet-topology, \
dashlet-url, \
dashlet-surveillance, \
vaadin-surveillance-views, \
vaadin-jmxconfiggenerator, \
vaadin-adminpage, \
org.opennms.features.bsm.shell-commands, \
geolocation, \
ifttt-integration, \
opennms-endpoints-grafana, \
opennms-reporting, \
<% node['opennms']['karaf']['addl_features'].each do |v| -%>
<%=v%>, \
<% end -%>
opennms-karaf-health

# Ensure that the 'opennms-karaf-health' feature is installed *last*

#
# Resource repositories (OBR) that the features resolver can use
# to resolve requirements/capabilities
#
# The format of the resourceRepositories is
# resourceRepositories=[xml:url|json:url],...
# for Instance:
#
#resourceRepositories=xml:http://host/path/to/index.xml
# or
#resourceRepositories=json:http://host/path/to/index.json
#

#
# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
#
featuresBootAsynchronous=false

#
# Service requirements enforcement
#
# By default, the feature resolver checks the service requirements/capabilities of
# bundles for new features (xml schema >= 1.3.0) in order to automatically installs
# the required bundles.
# The following flag can have those values:
# - disable: service requirements are completely ignored
# - default: service requirements are ignored for old features
# - enforce: service requirements are always verified
#
# OPENNMS: We need to disable this so that Pax Web doesn't complain about bring run
# inside our Felix bridge HTTP service (which does not implement the Pax Web services)
serviceRequirements=disable

#
# Store cfg file for config element in feature
#
#configCfgStore=true

#
# Configuration of features processing mechanism (overrides, blacklisting, modification of features)
# XML file defines instructions related to features processing
# versions.properties may declare properties to resolve placeholders in XML file
# both files are relative to ${karaf.etc}
#
#featureProcessing=org.apache.karaf.features.xml
#featureProcessingVersions=versions.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% node['opennms']['kafka']['producer'].each do |k,v| -%>
<%=k%>=<%=v%>
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% node['opennms']['kafka']['producer_client'].each do |k,v| -%>
<%=k%>=<%=v%>
<% end -%>
25 changes: 25 additions & 0 deletions test/integration/kafka/kafka_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe file('/opt/opennms/etc/org.opennms.features.kafka.producer.client.cfg') do
its('content') { should include 'bootstrap.servers=127.0.0.1:9092' }
end

describe file('/opt/opennms/etc/org.opennms.features.kafka.producer.cfg') do
its('content') { should include 'eventTopic=events' }
its('content') { should include 'alarmTopic=alarms' }
its('content') { should include 'alarmFeedbackTopic=alarmFeedback' }
its('content') { should include 'nodeTopic=nodes' }
its('content') { should include 'topologyVertexTopic=vertices' }
its('content') { should include 'topologyEdgeTopic=edges' }
its('content') { should include 'metricTopic=metrics' }
its('content') { should include 'eventFilter=' }
its('content') { should include 'alarmFilter=' }
its('content') { should include 'forward.metrics=false' }
its('content') { should include 'nodeRefreshTimeoutMs=300000' }
its('content') { should include 'alarmSyncIntervalMs=300000' }
its('content') { should include 'suppressIncrementalAlarms=true' }
its('content') { should include 'kafkaSendQueueCapacity=1000' }
its('content') { should include 'startAlarmSyncWithCleanState=false' }
end

describe file('/opt/opennms/etc/org.apache.karaf.features.cfg') do
its('content') { should include 'opennms-kafka-producer' }
end