Add configuration of host_aggregate_re for libvirt plugin

Change-Id: I1380afc5144695156eb62929b4910eff15b2ae4b
This commit is contained in:
Brad Klein 2017-03-06 13:08:07 -07:00
parent 39465dfe31
commit e966b524e2
3 changed files with 65 additions and 0 deletions

View File

@ -36,6 +36,12 @@
# period, it will be ignored.
# Defaults to 0.
#
# [*host_aggregate_re*]
# (Optional) Regular expression of host aggregate names to match, which
# will add a 'host_aggregate' dimension to libvirt metrics for the operations
# project.
# Defaults to undef -- causing the flag to not be set in the config file.
#
# [*identity_uri*]
# (Required) URI of the keystone instance.
#
@ -98,6 +104,7 @@ class monasca::checks::libvirt(
$cache_dir = '/dev/shm',
$customer_metadata = [],
$disk_collection_period = 0,
$host_aggregate_re = undef,
$identity_uri = undef,
$metadata = [],
$network_use_bits = true,

View File

@ -0,0 +1,55 @@
require 'spec_helper'
describe 'monasca::checks::libvirt' do
describe 'on debian platforms' do
let :facts do
@default_facts.merge({
:osfamily => 'Debian',
})
end
let :libvirt_file do
"/etc/monasca/agent/conf.d/libvirt.yaml"
end
let :pre_condition do
"class { 'monasca::agent':
url => 'http://127.0.0.1',
username => 'user',
password => 'password',
keystone_url => 'http://127.0.0.1:5000',
install_python_deps => false,
}"
end
let(:params) { {
:admin_password => 'password',
:admin_tenant_name => 'tenant_name',
:admin_user => 'user',
:identity_uri => 'uri',
:host_aggregate_re => 'M4',
} }
it 'builds the libvirt config file properly' do
is_expected.to contain_file(libvirt_file).with_content(/^\s*admin_password: password$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*admin_tenant_name: tenant_name$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*admin_user: user$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*identity_uri: uri$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*cache_dir: \/dev\/shm$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*nova_refresh: 14400$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*network_use_bits: true$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*metadata: \[\]$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*customer_metadata: \[\]$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_probation: 300$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*ping_check: false$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*alive_only: false$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*disk_collection_period: 0$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_cpu_check_enable: true$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_disks_check_enable: true$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_network_check_enable: true$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_ping_check_enable: false$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*vm_extended_disks_check_enable: false$/)
is_expected.to contain_file(libvirt_file).with_content(/^\s*host_aggregate_re: M4$/)
end
end
end

View File

@ -27,6 +27,9 @@ init_config:
vm_network_check_enable: <%= @vm_network_check_enable %>
vm_ping_check_enable: <%= @vm_ping_check_enable %>
vm_extended_disks_check_enable: <%= @vm_extended_disks_check_enable %>
<%- if @host_aggregate_re -%>
host_aggregate_re: <%= @host_aggregate_re %>
<%- end -%>
instances:
- {}