-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
Add class ovs_events plugin #743
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#== Class: collectd::plugin::ovs_events | ||
# | ||
# Class to manage ovs_events plugin for collectd | ||
# | ||
# Documentation: | ||
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_ovs_events | ||
# | ||
# === Parameters | ||
# | ||
# [* address *] | ||
# The address of the OVS DB server JSON-RPC interface used by the plugin. | ||
# | ||
# [*dispatch*] | ||
# Dispatch the OVS DB interface link status value with configured plugin | ||
# interval. | ||
# | ||
# [*ensure*] | ||
# ensure param for collectd::plugin type. | ||
# Defaults to 'ensure' | ||
# | ||
# [* interfaces *] | ||
# List of interface names to be monitored by this plugin. If this option | ||
# is not specified or is empty then all OVS connected interfaces | ||
# on all bridges are monitored. | ||
# | ||
# [*manage_package*] | ||
# If enabled, manages separate package for plugin | ||
# Defaults to true | ||
# | ||
# [*send_notification*] | ||
# If set to true, OVS link notifications (interface status and | ||
# OVS DB connection terminate) are sent to collectd. | ||
# | ||
# [*package_name*] | ||
# If manage_package is true, this gives the name of the package to manage. | ||
# Defaults to 'collectd-ovs_stats' | ||
# | ||
# [*port*] | ||
# TCP-port to connect to. Either a service name or a port number may be given. | ||
# | ||
# [*socket*] | ||
# The UNIX domain socket path of OVS DB server JSON-RPC interface used | ||
# by the plugin | ||
# | ||
class collectd::plugin::ovs_events ( | ||
Optional[Stdlib::Host] $address = undef, | ||
Optional[Boolean] $dispatch = undef, | ||
String $ensure = 'present', | ||
Optional[Array] $interfaces = [], | ||
Boolean $manage_package = true, | ||
Optional[Boolean] $send_notification = undef, | ||
String $package_name = 'collectd-ovs-events', | ||
Optional[Integer] $port = undef, | ||
Optional[String] $socket = undef, | ||
) { | ||
|
||
include ::collectd | ||
|
||
if $manage_package { | ||
package { 'collectd-ovs-events': | ||
ensure => $ensure, | ||
name => $package_name, | ||
} | ||
} | ||
|
||
collectd::plugin { 'ovs_events': | ||
ensure => $ensure, | ||
content => template('collectd/plugin/ovs_events.conf.erb'), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::ovs_events', type: :class do | ||
on_supported_os(test_on).each do |os, facts| | ||
context "on #{os} " do | ||
let :facts do | ||
facts | ||
end | ||
|
||
options = os_specific_options(facts) | ||
|
||
context ':ensure => present' do | ||
let :params do | ||
{ address: 'foo.bar.baz', | ||
interfaces: %w[bar baz], | ||
port: 666, | ||
socket: '/foo/bar/baz', | ||
send_notification: true, | ||
dispatch: false } | ||
end | ||
|
||
it "will create #{options[:plugin_conf_dir]}/10-ovs_events.conf" do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/10-ovs_events.conf" | ||
) | ||
end | ||
|
||
it 'will create config which will contain port configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{Port 666} | ||
) | ||
end | ||
|
||
it 'will create config which will contain address configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{Address "foo.bar.baz"} | ||
) | ||
end | ||
|
||
it 'will create config which will contain socket configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{Socket "/foo/bar/baz"} | ||
) | ||
end | ||
|
||
it 'will create config which will contain interfaces configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{Interfaces "bar" "baz"} | ||
) | ||
end | ||
|
||
it 'will create config which will contain send_notification configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{SendNotification true} | ||
) | ||
end | ||
|
||
it 'will create config which will contain dispatch configuration' do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
content: %r{DispatchValues false} | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
|
||
it "will not create #{options[:plugin_conf_dir]}/10-ovs_events.conf" do | ||
is_expected.to contain_file('ovs_events.load').with( | ||
ensure: 'absent', | ||
path: "#{options[:plugin_conf_dir]}/10-ovs_events.conf" | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Plugin "ovs_events"> | ||
<%- if @port %> | ||
Port <%= @port %> | ||
<%- end -%> | ||
<%- if @address %> | ||
Address "<%= @address %>" | ||
<%- end -%> | ||
<%- if @socket %> | ||
Socket "<%= @socket %>" | ||
<%- end -%> | ||
<%- if !@interfaces.empty? %> | ||
Interfaces "<%= @interfaces.join('" "') %>" | ||
<%- end -%> | ||
<%- if defined?(@send_notification) %> | ||
SendNotification <%= @send_notification %> | ||
<%- end -%> | ||
<%- if defined?(@dispatch) %> | ||
DispatchValues <%= @dispatch %> | ||
<%- end -%> | ||
</Plugin> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datatypes \o/