Ceilometer integration
* BP: ceilometer-fuel-integraition * HA and simple deployment * general MySQL backend for ceilometer * tested on CentOS 6.4 * need verification of Ubuntu support
This commit is contained in:
parent
797fc91a64
commit
1743c7e76b
|
@ -0,0 +1,9 @@
|
|||
fixtures:
|
||||
repositories:
|
||||
"inifile": "git://github.com/cprice-puppet/puppetlabs-inifile"
|
||||
"keystone": "git://github.com/stackforge/puppet-keystone.git"
|
||||
"mysql": "git://github.com/puppetlabs/puppetlabs-mysql.git"
|
||||
"nova": "git://github.com/stackforge/puppet-nova.git"
|
||||
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
||||
symlinks:
|
||||
"ceilometer": "#{source_dir}"
|
|
@ -0,0 +1,4 @@
|
|||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=stackforge/puppet-ceilometer.git
|
|
@ -0,0 +1,28 @@
|
|||
language: ruby
|
||||
bundler_args: --without development
|
||||
before_script:
|
||||
- echo $PUPPET_GEM_VERSION | grep '2.6' && git clone git://github.com/puppetlabs/puppetlabs-create_resources.git spec/fixtures/modules/create_resources || true
|
||||
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- ruby-head
|
||||
env:
|
||||
- PUPPET_GEM_VERSION="~> 2.6"
|
||||
- PUPPET_GEM_VERSION="~> 2.7"
|
||||
- PUPPET_GEM_VERSION="~> 3.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.1"
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
exclude:
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 2.7"
|
||||
- rvm: ruby-head
|
||||
env: PUPPET_GEM_VERSION="~> 2.7"
|
||||
- rvm: 1.9.3
|
||||
env: PUPPET_GEM_VERSION="~> 2.6"
|
||||
- rvm: ruby-head
|
||||
env: PUPPET_GEM_VERSION="~> 2.6"
|
||||
notifications:
|
||||
email: false
|
|
@ -0,0 +1,14 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'puppet-lint', '~> 0.3.2'
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
||||
|
||||
# vim:ft=ruby
|
|
@ -0,0 +1,174 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
|
@ -0,0 +1,13 @@
|
|||
name 'enovance-ceilometer'
|
||||
version '0.0.1'
|
||||
source 'none'
|
||||
author 'enovance'
|
||||
license 'Apache License, Version 2.0'
|
||||
summary 'Install/configure Openstack Ceilometer'
|
||||
description 'Install/configure Openstack Ceilometer'
|
||||
project_page 'https://launchpad.net/ceilometer'
|
||||
|
||||
# Dependencies
|
||||
dependency 'puppetlabs/stdlib', '>= 3.2.0'
|
||||
dependency 'cprice404/inifile', '>= 0.9.0'
|
||||
dependency 'puppetlabs/mysql', '>= 0.5.0'
|
|
@ -0,0 +1,27 @@
|
|||
puppet-ceilometer
|
||||
|
||||
This is the ceilometer module.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Apache License 2.0
|
||||
|
||||
Copyright 2012 eNovance <licensing@enovance.com>
|
||||
|
||||
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.
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
techs@enovance.com
|
|
@ -0,0 +1 @@
|
|||
require 'puppetlabs_spec_helper/rake_tasks'
|
|
@ -0,0 +1,35 @@
|
|||
node default {
|
||||
Exec {
|
||||
path => ['/usr/bin', '/bin', '/usr/sbin', '/sbin']
|
||||
}
|
||||
|
||||
# First, install a mysql server
|
||||
class { 'mysql::server': }
|
||||
# And create the database
|
||||
class { 'ceilometer::db::mysql':
|
||||
password => 'ceilometer',
|
||||
}
|
||||
|
||||
# Add the base ceilometer class & parameters
|
||||
# This class is required by ceilometer agents & api classes
|
||||
# The metering_secret parameter is mandatory
|
||||
class { 'ceilometer':
|
||||
metering_secret => 'darksecret'
|
||||
}
|
||||
|
||||
# Configure the ceilometer database
|
||||
# Only needed if ceilometer::agent::central or ceilometer::api are declared
|
||||
class { 'ceilometer::db':
|
||||
}
|
||||
|
||||
# Install the ceilometer-api service
|
||||
# The keystone_password parameter is mandatory
|
||||
class { 'ceilometer::api':
|
||||
keystone_password => 'tralalayouyou'
|
||||
}
|
||||
|
||||
# Install compute agent
|
||||
class { 'ceilometer::agent::compute':
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,321 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
#
|
||||
# OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)
|
||||
#
|
||||
# Description: Manages an OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) process as an HA resource
|
||||
#
|
||||
# Authors: Emilien Macchi
|
||||
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
|
||||
#
|
||||
# Support: openstack@lists.launchpad.net
|
||||
# License: Apache Software License (ASL) 2.0
|
||||
#
|
||||
#
|
||||
# See usage() function below for more details ...
|
||||
#
|
||||
# OCF instance parameters:
|
||||
# OCF_RESKEY_binary
|
||||
# OCF_RESKEY_config
|
||||
# OCF_RESKEY_user
|
||||
# OCF_RESKEY_pid
|
||||
# OCF_RESKEY_monitor_binary
|
||||
# OCF_RESKEY_additional_parameters
|
||||
#######################################################################
|
||||
# Initialization:
|
||||
|
||||
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
|
||||
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
|
||||
|
||||
#######################################################################
|
||||
|
||||
# Fill in some defaults if no values are specified
|
||||
|
||||
OCF_RESKEY_binary_default="ceilometer-agent-central"
|
||||
OCF_RESKEY_config_default="/etc/ceilometer/ceilometer.conf"
|
||||
OCF_RESKEY_user_default="ceilometer"
|
||||
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
|
||||
|
||||
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
|
||||
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
|
||||
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
|
||||
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
|
||||
|
||||
#######################################################################
|
||||
|
||||
usage() {
|
||||
cat <<UEND
|
||||
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
|
||||
|
||||
$0 manages an OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) process as an HA resource
|
||||
|
||||
The 'start' operation starts the scheduler service.
|
||||
The 'stop' operation stops the scheduler service.
|
||||
The 'validate-all' operation reports whether the parameters are valid
|
||||
The 'meta-data' operation reports this RA's meta-data information
|
||||
The 'status' operation reports whether the scheduler service is running
|
||||
The 'monitor' operation reports whether the scheduler service seems to be working
|
||||
|
||||
UEND
|
||||
}
|
||||
|
||||
meta_data() {
|
||||
cat <<END
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
|
||||
<resource-agent name="ceilometer-agent-central">
|
||||
<version>1.0</version>
|
||||
|
||||
<longdesc lang="en">
|
||||
Resource agent for the OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)
|
||||
May manage a ceilometer-agent-central instance or a clone set that
|
||||
creates a distributed ceilometer-agent-central cluster.
|
||||
</longdesc>
|
||||
<shortdesc lang="en">Manages the OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)</shortdesc>
|
||||
<parameters>
|
||||
|
||||
<parameter name="binary" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Location of the OpenStack Ceilometer Central Agent server binary (ceilometer-agent-central)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Central Agent server binary (ceilometer-agent-central)</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_binary_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="config" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Location of the OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) configuration file
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Central Agent (ceilometer-agent-central registry) config file</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_config_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="user" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
User running OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) user</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_user_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="pid" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
The pid file to use for this OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) instance
|
||||
</longdesc>
|
||||
<shortdesc lang="en">OpenStack Ceilometer Central Agent Service (ceilometer-agent-central) pid file</shortdesc>
|
||||
<content type="string" default="${OCF_RESKEY_pid_default}" />
|
||||
</parameter>
|
||||
|
||||
<parameter name="additional_parameters" unique="0" required="0">
|
||||
<longdesc lang="en">
|
||||
Additional parameters to pass on to the OpenStack Ceilometer Central Agent Service (ceilometer-agent-central)
|
||||
</longdesc>
|
||||
<shortdesc lang="en">Additional parameters for ceilometer-agent-central</shortdesc>
|
||||
<content type="string" />
|
||||
</parameter>
|
||||
|
||||
</parameters>
|
||||
|
||||
<actions>
|
||||
<action name="start" timeout="20" />
|
||||
<action name="stop" timeout="20" />
|
||||
<action name="status" timeout="20" />
|
||||
<action name="monitor" timeout="30" interval="20" />
|
||||
<action name="validate-all" timeout="5" />
|
||||
<action name="meta-data" timeout="5" />
|
||||
</actions>
|
||||
</resource-agent>
|
||||
END
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Functions invoked by resource manager actions
|
||||
|
||||
ceilometer_agent_central_check_port() {
|
||||
# This function has been taken from the squid RA and improved a bit
|
||||
# The length of the integer must be 4
|
||||
# Examples of valid port: "1080", "0080"
|
||||
# Examples of invalid port: "1080bad", "0", "0000", ""
|
||||
|
||||
local int
|
||||
local cnt
|
||||
|
||||
int="$1"
|
||||
cnt=${#int}
|
||||
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
|
||||
|
||||
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
|
||||
ocf_log err "Invalid port number: $1"
|
||||
exit $OCF_ERR_CONFIGURED
|
||||
fi
|
||||
}
|
||||
|
||||
ceilometer_agent_central_validate() {
|
||||
local rc
|
||||
|
||||
check_binary $OCF_RESKEY_binary
|
||||
check_binary netstat
|
||||
|
||||
# A config file on shared storage that is not available
|
||||
# during probes is OK.
|
||||
if [ ! -f $OCF_RESKEY_config ]; then
|
||||
if ! ocf_is_probe; then
|
||||
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
|
||||
return $OCF_ERR_INSTALLED
|
||||
fi
|
||||
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
|
||||
fi
|
||||
|
||||
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "User $OCF_RESKEY_user doesn't exist"
|
||||
return $OCF_ERR_INSTALLED
|
||||
fi
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
ceilometer_agent_central_status() {
|
||||
local pid
|
||||
local rc
|
||||
|
||||
if [ ! -f $OCF_RESKEY_pid ]; then
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) is not running"
|
||||
return $OCF_NOT_RUNNING
|
||||
else
|
||||
pid=`cat $OCF_RESKEY_pid`
|
||||
fi
|
||||
|
||||
ocf_run -warn kill -s 0 $pid
|
||||
rc=$?
|
||||
if [ $rc -eq 0 ]; then
|
||||
return $OCF_SUCCESS
|
||||
else
|
||||
ocf_log info "Old PID file found, but OpenStack Ceilometer Central Agent (ceilometer-agent-central) is not running"
|
||||
return $OCF_NOT_RUNNING
|
||||
fi
|
||||
}
|
||||
|
||||
ceilometer_agent_central_monitor() {
|
||||
local rc
|
||||
local pid
|
||||
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
|
||||
# If status returned anything but success, return that immediately
|
||||
if [ $rc -ne $OCF_SUCCESS ]; then
|
||||
return $rc
|
||||
fi
|
||||
|
||||
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-central) monitor succeeded"
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
ceilometer_agent_central_start() {
|
||||
local rc
|
||||
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_SUCCESS ]; then
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) already running"
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
# run the actual ceilometer-agent-central daemon. Don't use ocf_run as we're sending the tool's output
|
||||
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
|
||||
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
|
||||
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
|
||||
|
||||
# Spin waiting for the server to come up.
|
||||
while true; do
|
||||
ceilometer_agent_central_monitor
|
||||
rc=$?
|
||||
[ $rc -eq $OCF_SUCCESS ] && break
|
||||
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-central) start failed"
|
||||
exit $OCF_ERR_GENERIC
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) started"
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
ceilometer_agent_central_stop() {
|
||||
local rc
|
||||
local pid
|
||||
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) already stopped"
|
||||
return $OCF_SUCCESS
|
||||
fi
|
||||
|
||||
# Try SIGTERM
|
||||
pid=`cat $OCF_RESKEY_pid`
|
||||
ocf_run kill -s TERM $pid
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-central) couldn't be stopped"
|
||||
exit $OCF_ERR_GENERIC
|
||||
fi
|
||||
|
||||
# stop waiting
|
||||
shutdown_timeout=15
|
||||
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
|
||||
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
|
||||
fi
|
||||
count=0
|
||||
while [ $count -lt $shutdown_timeout ]; do
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
if [ $rc -eq $OCF_NOT_RUNNING ]; then
|
||||
break
|
||||
fi
|
||||
count=`expr $count + 1`
|
||||
sleep 1
|
||||
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-central) still hasn't stopped yet. Waiting ..."
|
||||
done
|
||||
|
||||
ceilometer_agent_central_status
|
||||
rc=$?
|
||||
if [ $rc -ne $OCF_NOT_RUNNING ]; then
|
||||
# SIGTERM didn't help either, try SIGKILL
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) failed to stop after ${shutdown_timeout}s \
|
||||
using SIGTERM. Trying SIGKILL ..."
|
||||
ocf_run kill -s KILL $pid
|
||||
fi
|
||||
|
||||
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-central) stopped"
|
||||
|
||||
rm -f $OCF_RESKEY_pid
|
||||
|
||||
return $OCF_SUCCESS
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
|
||||
case "$1" in
|
||||
meta-data) meta_data
|
||||
exit $OCF_SUCCESS;;
|
||||
usage|help) usage
|
||||
exit $OCF_SUCCESS;;
|
||||
esac
|
||||
|
||||
# Anything except meta-data and help must pass validation
|
||||
ceilometer_agent_central_validate || exit $?
|
||||
|
||||
# What kind of method was invoked?
|
||||
case "$1" in
|
||||
start) ceilometer_agent_central_start;;
|
||||
stop) ceilometer_agent_central_stop;;
|
||||
status) ceilometer_agent_central_status;;
|
||||
monitor) ceilometer_agent_central_monitor;;
|
||||
validate-all) ;;
|
||||
*) usage
|
||||
exit $OCF_ERR_UNIMPLEMENTED;;
|
||||
esac
|
|
@ -0,0 +1,22 @@
|
|||
Puppet::Type.type(:ceilometer_config).provide(
|
||||
:ini_setting,
|
||||
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
|
||||
) do
|
||||
|
||||
def section
|
||||
resource[:name].split('/', 2).first
|
||||
end
|
||||
|
||||
def setting
|
||||
resource[:name].split('/', 2).last
|
||||
end
|
||||
|
||||
def separator
|
||||
'='
|
||||
end
|
||||
|
||||
def file_path
|
||||
'/etc/ceilometer/ceilometer.conf'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
Puppet::Type.newtype(:ceilometer_config) do
|
||||
|
||||
ensurable
|
||||
|
||||
newparam(:name, :namevar => true) do
|
||||
desc 'Section/setting name to manage from ceilometer.conf'
|
||||
newvalues(/\S+\/\S+/)
|
||||
end
|
||||
|
||||
newproperty(:value) do
|
||||
desc 'The value of the setting to be defined.'
|
||||
munge do |value|
|
||||
value = value.to_s.strip
|
||||
value.capitalize! if value =~ /^(true|false)$/i
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,139 @@
|
|||
# Installs/configures the ceilometer central agent
|
||||
#
|
||||
# == Parameters
|
||||
# [*auth_url*]
|
||||
# Keystone URL. Optional. Defaults to 'http://localhost:5000/v2.0'
|
||||
#
|
||||
# [*auth_region*]
|
||||
# Keystone region. Optional. Defaults to 'RegionOne'
|
||||
#
|
||||
# [*auth_user*]
|
||||
# Keystone user for ceilometer. Optional. Defaults to 'ceilometer'
|
||||
#
|
||||
# [*auth_password*]
|
||||
# Keystone password for ceilometer. Optional. Defaults to 'password'
|
||||
#
|
||||
# [*auth_tenant_name*]
|
||||
# Keystone tenant name for ceilometer. Optional. Defauls to 'services'
|
||||
#
|
||||
# [*auth_tenant_id*]
|
||||
# Keystone tenant id for ceilometer. Optional. Defaults to ''
|
||||
#
|
||||
# [*enabled*]
|
||||
# Should the service be enabled. Optional. Defauls to true
|
||||
#
|
||||
class ceilometer::agent::central (
|
||||
$auth_host = 'http://localhost:5000/v2.0',
|
||||
$auth_region = 'RegionOne',
|
||||
$auth_user = 'ceilometer',
|
||||
$auth_password = 'password',
|
||||
$auth_tenant_name = 'services',
|
||||
$auth_tenant_id = '',
|
||||
$enabled = true,
|
||||
$ha_mode = false,
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-agent-central']
|
||||
Package['ceilometer-common'] -> Service['ceilometer-agent-central']
|
||||
Package['ceilometer-agent-central'] -> Service['ceilometer-agent-central']
|
||||
|
||||
package { 'ceilometer-agent-central':
|
||||
ensure => installed,
|
||||
name => $::ceilometer::params::agent_central_package_name,
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'DEFAULT/os_auth_url' : value => "http://${auth_host}:5000/v2.0";
|
||||
'DEFAULT/os_auth_region' : value => $auth_region;
|
||||
'DEFAULT/os_username' : value => $auth_user;
|
||||
'DEFAULT/os_password' : value => $auth_password;
|
||||
'DEFAULT/os_tenant_name' : value => $auth_tenant_name;
|
||||
}
|
||||
|
||||
if ($auth_tenant_id != '') {
|
||||
ceilometer_config {
|
||||
'DEFAULT/os_tenant_id' : value => $auth_tenant_id;
|
||||
}
|
||||
}
|
||||
|
||||
if $ha_mode {
|
||||
|
||||
$res_name = "p_${::ceilometer::params::agent_central_service_name}"
|
||||
$cib_name = "${::ceilometer::params::agent_central_service_name}"
|
||||
|
||||
Package['pacemaker'] -> File['ceilometer-agent-central-ocf']
|
||||
file {'ceilometer-agent-central-ocf':
|
||||
path=>'/usr/lib/ocf/resource.d/mirantis/ceilometer-agent-central',
|
||||
mode => 755,
|
||||
owner => root,
|
||||
group => root,
|
||||
source => 'puppet:///modules/ceilometer/ocf/ceilometer-agent-central',
|
||||
}
|
||||
|
||||
File['ceilometer-agent-central-ocf'] -> Cs_resource[$res_name]
|
||||
cs_resource { $res_name:
|
||||
ensure => present,
|
||||
cib => $cib_name,
|
||||
primitive_class => 'ocf',
|
||||
provided_by => 'mirantis',
|
||||
primitive_type => 'ceilometer-agent-central',
|
||||
metadata => { 'target-role' => 'stopped' },
|
||||
parameters => { 'user' => 'ceilometer' },
|
||||
operations => {
|
||||
'monitor' => {
|
||||
'interval' => '20',
|
||||
'timeout' => '30'
|
||||
}
|
||||
,
|
||||
'start' => {
|
||||
'timeout' => '360'
|
||||
}
|
||||
,
|
||||
'stop' => {
|
||||
'timeout' => '360'
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
cs_shadow { $res_name: cib => $cib_name }
|
||||
cs_commit { $res_name: cib => $cib_name }
|
||||
|
||||
::corosync::cleanup{ $res_name: }
|
||||
|
||||
service { 'ceilometer-agent-central':
|
||||
ensure => $service_ensure,
|
||||
name => $res_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
provider => "pacemaker",
|
||||
}
|
||||
|
||||
Cs_commit[$res_name] -> ::Corosync::Cleanup[$res_name]
|
||||
Cs_commit[$res_name] ~> ::Corosync::Cleanup[$res_name]
|
||||
|
||||
Cs_shadow[$res_name] ->
|
||||
Cs_resource[$res_name] ->
|
||||
Cs_commit[$res_name] ->
|
||||
Service['ceilometer-agent-central']
|
||||
|
||||
} else {
|
||||
|
||||
service { 'ceilometer-agent-central':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::agent_central_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
# The ceilometer::agent::compute class installs the ceilometer compute agent
|
||||
# Include this class on all nova compute nodes
|
||||
#
|
||||
# == Parameters
|
||||
# [*auth_url*]
|
||||
# the keystone public endpoint
|
||||
# Optional. Defaults to 'http://localhost:5000/v2.0'
|
||||
#
|
||||
# [*auth_region*]
|
||||
# the keystone region of this compute node
|
||||
# Optional. Defaults to 'RegionOne'
|
||||
#
|
||||
# [*auth_user*]
|
||||
# the keystone user for ceilometer services
|
||||
# Optional. Defaults to 'ceilometer'
|
||||
#
|
||||
# [*auth_password*]
|
||||
# the keystone password for ceilometer services
|
||||
# Optional. Defaults to 'password'
|
||||
#
|
||||
# [*auth_tenant_name*]
|
||||
# the keystone tenant name for ceilometer services
|
||||
# Optional. Defaults to 'services'
|
||||
#
|
||||
# [*auth_tenant_id*]
|
||||
# the keystone tenant id for ceilometer services.
|
||||
# Optional. Defaults to empty.
|
||||
#
|
||||
# [*enabled*]
|
||||
# should the service be started or not
|
||||
# Optional. Defaults to true
|
||||
#
|
||||
class ceilometer::agent::compute (
|
||||
$auth_host = '127.0.0.1',
|
||||
$auth_region = 'RegionOne',
|
||||
$auth_user = 'ceilometer',
|
||||
$auth_password = 'password',
|
||||
$auth_tenant_name = 'services',
|
||||
$auth_tenant_id = '',
|
||||
$enabled = true,
|
||||
) inherits ceilometer {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-agent-compute']
|
||||
|
||||
Package['ceilometer-agent-compute'] -> Service['ceilometer-agent-compute']
|
||||
package { 'ceilometer-agent-compute':
|
||||
ensure => installed,
|
||||
name => $::ceilometer::params::agent_compute_package_name,
|
||||
}
|
||||
|
||||
if $::ceilometer::params::libvirt_group {
|
||||
User['ceilometer'] {
|
||||
groups +> [$::ceilometer::params::libvirt_group]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
Package['ceilometer-common'] -> Service['ceilometer-agent-compute']
|
||||
service { 'ceilometer-agent-compute':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::agent_compute_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'DEFAULT/os_auth_url' : value => "http://${auth_host}:5000/v2.0";
|
||||
'DEFAULT/os_auth_region' : value => $auth_region;
|
||||
'DEFAULT/os_username' : value => $auth_user;
|
||||
'DEFAULT/os_password' : value => $auth_password;
|
||||
'DEFAULT/os_tenant_name' : value => $auth_tenant_name;
|
||||
}
|
||||
|
||||
if ($auth_tenant_id != '') {
|
||||
ceilometer_config {
|
||||
'DEFAULT/os_tenant_id' : value => $auth_tenant_id;
|
||||
}
|
||||
}
|
||||
|
||||
nova_config {
|
||||
'DEFAULT/instance_usage_audit' : value => 'True';
|
||||
'DEFAULT/instance_usage_audit_period' : value => 'hour';
|
||||
'DEFAULT/notification_driver':
|
||||
value => 'nova.openstack.common.notifier.rpc_notifier,ceilometer.compute.nova_notifier';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
class ceilometer::alarm::evaluator (
|
||||
$enabled = true,
|
||||
)
|
||||
{
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['service-alarm-evaluator']
|
||||
Package[$::ceilometer::params::alarm_evaluator_package] -> Service['service-alarm-evaluator']
|
||||
|
||||
if ! defined(Package[$::ceilometer::params::alarm_evaluator_package]) {
|
||||
package { $::ceilometer::params::alarm_evaluator_package:
|
||||
ensure => installed,
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
}
|
||||
else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
service { 'service-alarm-evaluator':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::alarm_evaluator_service,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
class ceilometer::alarm::notifier (
|
||||
$enabled = true,
|
||||
)
|
||||
{
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['service-alarm-notifier']
|
||||
Package[$::ceilometer::params::alarm_notifier_package] -> Service['service-alarm-notifier']
|
||||
|
||||
if ! defined(Package[$::ceilometer::params::alarm_notifier_package]) {
|
||||
package { $::ceilometer::params::alarm_notifier_package :
|
||||
ensure => installed,
|
||||
}
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
}
|
||||
else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
service { 'service-alarm-notifier':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::alarm_notifier_service,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
# Installs & configure the ceilometer api service
|
||||
#
|
||||
# == Parameters
|
||||
# [*enabled*]
|
||||
# should the service be enabled. Optional. Defaults to true
|
||||
#
|
||||
# [*keystone_host*]
|
||||
# keystone's admin endpoint IP/Host. Optional. Defaults to 127.0.0.1
|
||||
#
|
||||
# [*keystone_port*]
|
||||
# keystone's admin endpoint port. Optional. Defaults to 35357
|
||||
#
|
||||
# [*keystone_auth_admin_prefix*]
|
||||
# 'path' to the keystone admin endpoint. Optional. Defaults to false (empty)
|
||||
# Define to a path starting with a '/' and without trailing '/'.
|
||||
# Eg.: '/keystone/admin' to match keystone::wsgi::apache default.
|
||||
#
|
||||
# [*keystone_protocol*] http/https
|
||||
# Optional. Defaults to https
|
||||
#
|
||||
# [*keytone_user*] user to authenticate with
|
||||
# Optional. Defaults to ceilometer
|
||||
#
|
||||
# [*keystone_tenant*] tenant to authenticate with
|
||||
# Optional. Defaults to services
|
||||
#
|
||||
# [*keystone_password*] password to authenticate with
|
||||
# Mandatory.
|
||||
#
|
||||
class ceilometer::api (
|
||||
$enabled = true,
|
||||
$keystone_host = '127.0.0.1',
|
||||
$keystone_port = '35357',
|
||||
$keystone_auth_admin_prefix = false,
|
||||
$keystone_protocol = 'http',
|
||||
$keystone_user = 'ceilometer',
|
||||
$keystone_tenant = 'services',
|
||||
$keystone_password = false,
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '8777',
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
validate_string($keystone_password)
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-api']
|
||||
|
||||
Package['ceilometer-api'] -> Ceilometer_config<||>
|
||||
Package['ceilometer-api'] -> Service['ceilometer-api']
|
||||
package { 'ceilometer-api':
|
||||
ensure => installed,
|
||||
name => $::ceilometer::params::api_package_name,
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
Package['ceilometer-common'] -> Service['ceilometer-api']
|
||||
service { 'ceilometer-api':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::api_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => Class['ceilometer::db'],
|
||||
subscribe => Exec['ceilometer-dbsync']
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'keystone_authtoken/auth_host' : value => $keystone_host;
|
||||
'keystone_authtoken/auth_port' : value => $keystone_port;
|
||||
'keystone_authtoken/auth_protocol' : value => $keystone_protocol;
|
||||
'keystone_authtoken/admin_tenant_name' : value => $keystone_tenant;
|
||||
'keystone_authtoken/admin_user' : value => $keystone_user;
|
||||
'keystone_authtoken/admin_password' : value => $keystone_password;
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'api/host': value => $bind_host;
|
||||
'api/port': value => $bind_port;
|
||||
}
|
||||
|
||||
# endpoint encryption
|
||||
if $keystone_protocol == '___https___' {
|
||||
ceilometer_config {
|
||||
'ssl/cert_file': value => $::ceilometer::params::ssl_cert_file;
|
||||
'ssl/key_file': value => $::ceilometer::params::ssl_key_file;
|
||||
# 'ssl/ca_file': value => $::ceilometer::params::ssl_ca_file;
|
||||
}
|
||||
|
||||
User['ceilometer'] {
|
||||
groups +> ['ssl-cert']
|
||||
}
|
||||
}
|
||||
|
||||
if $keystone_auth_admin_prefix {
|
||||
validate_re($keystone_auth_admin_prefix, '^(/.+[^/])?$')
|
||||
ceilometer_config {
|
||||
'keystone_authtoken/auth_admin_prefix': value => $keystone_auth_admin_prefix;
|
||||
}
|
||||
} else {
|
||||
ceilometer_config {
|
||||
'keystone_authtoken/auth_admin_prefix': ensure => absent;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# Installs the ceilometer python library.
|
||||
#
|
||||
# == parameters
|
||||
# [*ensure*]
|
||||
# ensure state for pachage.
|
||||
#
|
||||
class ceilometer::client (
|
||||
$ensure = 'present'
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
package { 'python-ceilometerclient':
|
||||
ensure => $ensure,
|
||||
name => $::ceilometer::params::client_package_name,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
# Installs the ceilometer collector service
|
||||
#
|
||||
# == Params
|
||||
# [*enabled*]
|
||||
# should the service be enabled
|
||||
#
|
||||
class ceilometer::collector (
|
||||
$enabled = true,
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
Ceilometer_config<||> ~> Service['ceilometer-collector']
|
||||
|
||||
Package['ceilometer-collector'] -> Service['ceilometer-collector']
|
||||
package { 'ceilometer-collector':
|
||||
ensure => installed,
|
||||
name => $::ceilometer::params::collector_package_name,
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
Package['ceilometer-common'] -> Service['ceilometer-collector']
|
||||
service { 'ceilometer-collector':
|
||||
ensure => $service_ensure,
|
||||
name => $::ceilometer::params::collector_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => Class['ceilometer::db'],
|
||||
subscribe => Exec['ceilometer-dbsync']
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
# Configures the ceilometer database
|
||||
# This class will install the required libraries depending on the driver
|
||||
# specified in the connection_string parameter
|
||||
#
|
||||
# == Parameters
|
||||
# [*database_connection*]
|
||||
# the connection string. format: [driver]://[user]:[password]@[host]/[database]
|
||||
#
|
||||
class ceilometer::db (
|
||||
$database_connection = 'mysql://ceilometer:ceilometer@localhost/ceilometer'
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
Package<| title == 'ceilometer-common' |> -> Class['ceilometer::db']
|
||||
|
||||
validate_re($database_connection,
|
||||
'(sqlite|mysql|posgres|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
case $database_connection {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
include mysql::python
|
||||
}
|
||||
/^postgres:\/\//: {
|
||||
$backend_package = 'python-psycopg2'
|
||||
}
|
||||
/^mongodb:\/\//: {
|
||||
$backend_package = 'python-pymongo'
|
||||
}
|
||||
/^sqlite:\/\//: {
|
||||
$backend_package = 'python-pysqlite2'
|
||||
}
|
||||
default: {
|
||||
fail('Unsupported backend configured')
|
||||
}
|
||||
}
|
||||
|
||||
if $backend_package and !defined(Package[$backend_package]) {
|
||||
package {'ceilometer-backend-package':
|
||||
ensure => present,
|
||||
name => $backend_package,
|
||||
}
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'database/connection': value => $database_connection;
|
||||
}
|
||||
|
||||
Ceilometer_config['database/connection'] ~> Exec['ceilometer-dbsync']
|
||||
|
||||
exec { 'ceilometer-dbsync':
|
||||
command => $::ceilometer::params::dbsync_command,
|
||||
path => '/usr/bin',
|
||||
user => $::ceilometer::params::username,
|
||||
refreshonly => true,
|
||||
logoutput => on_failure,
|
||||
subscribe => Ceilometer_config['database/connection']
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
# The ceilometer::db::mysql class creates a MySQL database for ceilometer.
|
||||
# It must be used on the MySQL server
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# password to connect to the database. Mandatory.
|
||||
#
|
||||
# [*dbname*]
|
||||
# name of the database. Optional. Defaults to ceilometer.
|
||||
#
|
||||
# [*user*]
|
||||
# user to connect to the database. Optional. Defaults to ceilometer.
|
||||
#
|
||||
# [*host*]
|
||||
# the default source host user is allowed to connect from.
|
||||
# Optional. Defaults to 'localhost'
|
||||
#
|
||||
# [*allowed_hosts*]
|
||||
# other hosts the user is allowd to connect from.
|
||||
# Optional. Defaults to undef.
|
||||
#
|
||||
# [*charset*]
|
||||
# the database charset. Optional. Defaults to 'latin1'
|
||||
#
|
||||
class ceilometer::db::mysql(
|
||||
$password = false,
|
||||
$dbname = 'ceilometer',
|
||||
$user = 'ceilometer',
|
||||
$host = 'localhost',
|
||||
$allowed_hosts = undef,
|
||||
$charset = 'latin1',
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
|
||||
Class['mysql::server'] -> Class['ceilometer::db::mysql']
|
||||
Class['ceilometer::db::mysql'] -> Exec<| title == 'ceilometer-dbsync' |>
|
||||
Mysql::Db[$dbname] ~> Exec<| title == 'ceilometer-dbsync' |>
|
||||
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
#require => Class['mysql::config'],
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
|
||||
if $allowed_hosts {
|
||||
ceilometer::db::mysql::host_access { $allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
# Allow a user to access the ceilometer database
|
||||
#
|
||||
# == Namevar
|
||||
# The host to allow
|
||||
#
|
||||
# == Parameters
|
||||
# [*user*]
|
||||
# username to allow
|
||||
#
|
||||
# [*password*]
|
||||
# user password
|
||||
#
|
||||
# [*database*]
|
||||
# the database name
|
||||
#
|
||||
define ceilometer::db::mysql::host_access ($user, $password, $database) {
|
||||
|
||||
database_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
require => Database[$database],
|
||||
}
|
||||
|
||||
database_grant { "${user}@${name}/${database}":
|
||||
# TODO figure out which privileges to grant.
|
||||
privileges => 'all',
|
||||
provider => 'mysql',
|
||||
require => Database_user["${user}@${name}"]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
# Class ceilometer
|
||||
#
|
||||
# ceilometer base package & configuration
|
||||
#
|
||||
# == parameters
|
||||
# [*metering_secret*]
|
||||
# secret key for signing messages. Mandatory.
|
||||
# [*package_ensure*]
|
||||
# ensure state for package. Optional. Defaults to 'present'
|
||||
# [*verbose*]
|
||||
# should the daemons log verbose messages. Optional. Defaults to 'False'
|
||||
# [*debug*]
|
||||
# should the daemons log debug messages. Optional. Defaults to 'False'
|
||||
# [*rabbit_host*]
|
||||
# ip or hostname of the rabbit server. Optional. Defaults to '127.0.0.1'
|
||||
# [*rabbit_port*]
|
||||
# port of the rabbit server. Optional. Defaults to 5672.
|
||||
# [*rabbit_hosts*]
|
||||
# array of host:port (used with HA queues). Optional. Defaults to undef.
|
||||
# If defined, will remove rabbit_host & rabbit_port parameters from config
|
||||
# [*rabbit_userid*]
|
||||
# user to connect to the rabbit server. Optional. Defaults to 'guest'
|
||||
# [*rabbit_password*]
|
||||
# password to connect to the rabbit_server. Optional. Defaults to empty.
|
||||
# [*rabbit_virtual_host*]
|
||||
# virtualhost to use. Optional. Defaults to '/'
|
||||
#
|
||||
class ceilometer(
|
||||
$metering_secret = false,
|
||||
$package_ensure = 'present',
|
||||
$verbose = 'False',
|
||||
$debug = 'False',
|
||||
$use_syslog = false,
|
||||
$syslog_log_facility = 'SYSLOG',
|
||||
$syslog_log_level = 'WARNING',
|
||||
$queue_provider = 'rabbitmq',
|
||||
$rabbit_host = '127.0.0.1',
|
||||
$rabbit_port = 5672,
|
||||
$rabbit_userid = 'guest',
|
||||
$rabbit_password = '',
|
||||
$rabbit_virtual_host = '/',
|
||||
$qpid_host = '127.0.0.1',
|
||||
$qpid_nodes = false,
|
||||
$qpid_port = 5672,
|
||||
$qpid_userid = 'nova',
|
||||
$qpid_password = 'qpid_pw',
|
||||
) {
|
||||
|
||||
validate_string($metering_secret)
|
||||
|
||||
include ceilometer::params
|
||||
|
||||
File {
|
||||
require => Package['ceilometer-common'],
|
||||
}
|
||||
|
||||
group { 'ceilometer':
|
||||
name => 'ceilometer',
|
||||
require => Package['ceilometer-common'],
|
||||
}
|
||||
|
||||
user { 'ceilometer':
|
||||
name => 'ceilometer',
|
||||
gid => 'ceilometer',
|
||||
groups => ['nova'],
|
||||
system => true,
|
||||
require => Package['ceilometer-common'],
|
||||
}
|
||||
|
||||
file { '/etc/ceilometer/':
|
||||
ensure => directory,
|
||||
owner => 'ceilometer',
|
||||
group => 'ceilometer',
|
||||
mode => '0750',
|
||||
}
|
||||
|
||||
file { '/etc/ceilometer/ceilometer.conf':
|
||||
owner => 'ceilometer',
|
||||
group => 'ceilometer',
|
||||
mode => '0640',
|
||||
}
|
||||
|
||||
package { 'ceilometer-common':
|
||||
ensure => $package_ensure,
|
||||
name => $::ceilometer::params::common_package_name,
|
||||
}
|
||||
|
||||
Package['ceilometer-common'] -> Ceilometer_config<||>
|
||||
|
||||
# Configure RPC
|
||||
case $queue_provider {
|
||||
'rabbitmq': {
|
||||
ceilometer_config {
|
||||
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
|
||||
'DEFAULT/rabbit_password' : value => $rabbit_password;
|
||||
'DEFAULT/rabbit_virtual_host': value => $rabbit_virtual_host;
|
||||
'DEFAULT/rabbit_ha_queues' : value => true;
|
||||
'DEFAULT/rabbit_hosts' : value => "${rabbit_host}:${rabbit_port}"
|
||||
'DEFAULT/rpc_backend':
|
||||
value => 'ceilometer.openstack.common.rpc.impl_kombu';
|
||||
}
|
||||
}
|
||||
|
||||
'qpid': {
|
||||
ceilometer_config {
|
||||
'DEFAULT/qpid_username': value => $qpid_userid;
|
||||
'DEFAULT/qpid_password': value => $qpid_password;
|
||||
'DEFAULT/rpc_backend':
|
||||
value => 'ceilometer.openstack.common.rpc.impl_qpid';
|
||||
}
|
||||
if $qpid_nodes {
|
||||
ceilometer_config { 'DEFAULT/qpid_hosts':
|
||||
value => is_ip_address($qpid_nodes) ? {
|
||||
true => "${qpid_nodes}:${qpid_port}",
|
||||
false => join($qpid_nodes, ','),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ceilometer_config {
|
||||
'DEFAULT/qpid_hostname': value => $qpid_host;
|
||||
'DEFAULT/qpid_port' : value => $qpid_port;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ceilometer_config {
|
||||
'publisher_rpc/metering_secret' : value => $metering_secret;
|
||||
'DEFAULT/debug' : value => $debug;
|
||||
'DEFAULT/verbose' : value => $verbose;
|
||||
}
|
||||
|
||||
# Configure logging
|
||||
if $use_syslog and !$debug =~ /(?i)(true|yes)/ {
|
||||
File['ceilometer-logging.conf'] -> Ceilometer_config['DEFAULT/log_config']
|
||||
ceilometer_config {
|
||||
'DEFAULT/log_config' : value => '/etc/ceilometer/logging.conf';
|
||||
'DEFAULT/log_file' : ensure => absent;
|
||||
'DEFAULT/log_dir' : ensure => absent;
|
||||
'DEFAULT/use_stderr' : ensure => absent;
|
||||
'DEFAULT/use_syslog' : value => true;
|
||||
'DEFAULT/syslog_log_facility': value => $syslog_log_facility;
|
||||
}
|
||||
file { 'ceilometer-logging.conf':
|
||||
content => template('ceilometer/logging.conf.erb'),
|
||||
path => '/etc/ceilometer/logging.conf',
|
||||
}
|
||||
}
|
||||
else {
|
||||
ceilometer_config {
|
||||
'DEFAULT/log_config': ensure=> absent;
|
||||
'DEFAULT/use_syslog': ensure=> absent;
|
||||
'DEFAULT/syslog_log_facility': ensure=> absent;
|
||||
'DEFAULT/use_stderr': ensure=> absent;
|
||||
'DEFAULT/log_dir': value => $::ceilometer::params::log_dir;
|
||||
'DEFAULT/logging_context_format_string':
|
||||
value => '%(asctime)s %(levelname)s %(name)s [%(request_id)s %(user_id)s %(project_id)s] %(instance)s %(message)s';
|
||||
'DEFAULT/logging_default_format_string':
|
||||
value => '%(asctime)s %(levelname)s %(name)s [-] %(instance)s %(message)s';
|
||||
}
|
||||
# might be used for stdout logging instead, if configured
|
||||
file { 'ceilometer-logging.conf':
|
||||
content => template('ceilometer/logging.conf-nosyslog.erb'),
|
||||
path => '/etc/ceilometer/logging.conf',
|
||||
}
|
||||
}
|
||||
|
||||
# We must notify services to apply new logging rules
|
||||
File['ceilometer-logging.conf'] ~> Service<| title == "$::ceilometer::params::api_service_name" |>
|
||||
File['ceilometer-logging.conf'] ~> Service<| title == "$::ceilometer::params::collector_service_name" |>
|
||||
File['ceilometer-logging.conf'] ~> Service<| title == "$::ceilometer::params::agent_central_service_name" |>
|
||||
File['ceilometer-logging.conf'] ~> Service<| title == "$::ceilometer::params::agent_compute_service_name" |>
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
# == Class: ceilometer::keystone::auth
|
||||
#
|
||||
# Configures Ceilometer user, service and endpoint in Keystone.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# Password for Ceilometer user. Required.
|
||||
#
|
||||
# [*email*]
|
||||
# Email for Ceilometer user. Optional. Defaults to 'ceilometer@localhost'.
|
||||
#
|
||||
# [*auth_name*]
|
||||
# Username for Ceilometer service. Optional. Defaults to 'ceilometer'.
|
||||
#
|
||||
# [*configure_endpoint*]
|
||||
# Should Ceilometer endpoint be configured? Optional. Defaults to 'true'.
|
||||
#
|
||||
# [*service_type*]
|
||||
# Type of service. Optional. Defaults to 'metering'.
|
||||
#
|
||||
# [*public_address*]
|
||||
# Public address for endpoint. Optional. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*admin_address*]
|
||||
# Admin address for endpoint. Optional. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*internal_address*]
|
||||
# Internal address for endpoint. Optional. Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*port*]
|
||||
# Port for endpoint. Optional. Defaults to '8777'.
|
||||
#
|
||||
# [*region*]
|
||||
# Region for endpoint. Optional. Defaults to 'RegionOne'.
|
||||
#
|
||||
# [*tenant*]
|
||||
# Tenant for Ceilometer user. Optional. Defaults to 'services'.
|
||||
#
|
||||
# [*protocol*]
|
||||
# Protocol for public endpoint. Optional. Defaults to 'http'.
|
||||
#
|
||||
class ceilometer::keystone::auth (
|
||||
$password = false,
|
||||
$email = 'ceilometer@localhost',
|
||||
$auth_name = 'ceilometer',
|
||||
$service_type = 'metering',
|
||||
$public_address = '127.0.0.1',
|
||||
$admin_address = '127.0.0.1',
|
||||
$internal_address = '127.0.0.1',
|
||||
$port = '8777',
|
||||
$region = 'RegionOne',
|
||||
$tenant = 'services',
|
||||
$api_protocol = 'http',
|
||||
# $public_protocol = $api_protocol,
|
||||
# $admin_protocol = $api_protocol,
|
||||
# $internal_protocol = $api_protocol,
|
||||
$configure_endpoint = true
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
|
||||
Keystone_user_role["${auth_name}@${tenant}"] ~>
|
||||
Service <| name == 'ceilometer-api' |>
|
||||
|
||||
keystone_user { $auth_name:
|
||||
ensure => present,
|
||||
password => $password,
|
||||
email => $email,
|
||||
tenant => $tenant,
|
||||
}
|
||||
if !defined(Keystone_role['ResellerAdmin']) {
|
||||
keystone_role { 'ResellerAdmin':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
keystone_user_role { "${auth_name}@${tenant}":
|
||||
ensure => present,
|
||||
roles => ['admin', 'ResellerAdmin'],
|
||||
require => Keystone_role['ResellerAdmin'],
|
||||
}
|
||||
keystone_service { $auth_name:
|
||||
ensure => present,
|
||||
type => $service_type,
|
||||
description => 'Openstack Metering Service',
|
||||
}
|
||||
if $configure_endpoint {
|
||||
$public_protocol = $api_protocol
|
||||
$admin_protocol = $api_protocol
|
||||
$internal_protocol = $api_protocol
|
||||
|
||||
keystone_endpoint { "${auth_name}":
|
||||
region => $region,
|
||||
ensure => present,
|
||||
public_url => "${public_protocol}://${public_address}:${port}",
|
||||
admin_url => "${admin_protocol}://${admin_address}:${port}",
|
||||
internal_url => "${internal_protocol}://${internal_address}:${port}",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
# Parameters for puppet-ceilometer
|
||||
#
|
||||
class ceilometer::params {
|
||||
|
||||
$dbsync_command =
|
||||
'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf'
|
||||
$log_dir = '/var/log/ceilometer'
|
||||
|
||||
# ssl keys/certs
|
||||
$ssl_cert_file = '/etc/keystone/ssl/certs/signing_cert.pem'
|
||||
$ssl_key_file = '/etc/keystone/ssl/private/signing_key.pem'
|
||||
$ssl_ca_file = '/etc/keystone/ssl/certs/ca.pem'
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
# package names
|
||||
$agent_central_package_name = 'openstack-ceilometer-central'
|
||||
$agent_compute_package_name = 'openstack-ceilometer-compute'
|
||||
$api_package_name = 'openstack-ceilometer-api'
|
||||
$collector_package_name = 'openstack-ceilometer-collector'
|
||||
$common_package_name = 'openstack-ceilometer-common'
|
||||
$client_package_name = 'python-ceilometerclient'
|
||||
$alarm_evaluator_package = 'openstack-ceilometer-alarm'
|
||||
$alarm_notifier_package = 'openstack-ceilometer-alarm'
|
||||
# service names
|
||||
$agent_central_service_name = 'openstack-ceilometer-central'
|
||||
$agent_compute_service_name = 'openstack-ceilometer-compute'
|
||||
$api_service_name = 'openstack-ceilometer-api'
|
||||
$collector_service_name = 'openstack-ceilometer-collector'
|
||||
$alarm_evaluator_service = 'openstack-ceilometer-alarm-evaluator'
|
||||
$alarm_notifier_service = 'openstack-ceilometer-alarm-notifier'
|
||||
}
|
||||
'Debian': {
|
||||
# package names
|
||||
$agent_central_package_name = 'ceilometer-agent-central'
|
||||
$agent_compute_package_name = 'ceilometer-agent-compute'
|
||||
$api_package_name = 'ceilometer-api'
|
||||
$collector_package_name = 'ceilometer-collector'
|
||||
$common_package_name = 'ceilometer-common'
|
||||
$client_package_name = 'python-ceilometerclient'
|
||||
$alarm_evaluator_package = 'ceilometer-alarm-evaluator'
|
||||
$alarm_notifier_package = 'ceilometer-alarm-notifier'
|
||||
# service names
|
||||
$agent_central_service_name = 'ceilometer-agent-central'
|
||||
$agent_compute_service_name = 'ceilometer-agent-compute'
|
||||
$api_service_name = 'ceilometer-api'
|
||||
$collector_service_name = 'ceilometer-collector'
|
||||
$alarm_evaluator_service = 'ceilometer-alarm-evaluator'
|
||||
$alarm_notifier_service = 'ceilometer-alarm-notifier'
|
||||
# Operating system specific
|
||||
case $::operatingsystem {
|
||||
'Ubuntu': {
|
||||
$libvirt_group = 'libvirtd'
|
||||
}
|
||||
default: {
|
||||
$libvirt_group = 'libvirt'
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported osfamily: ${::osfamily} operatingsystem: \
|
||||
${::operatingsystem}, module ${module_name} only support osfamily \
|
||||
RedHat and Debian")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::agent::compute' do
|
||||
|
||||
let :pre_condition do
|
||||
"include nova\n" +
|
||||
"include nova::compute\n" +
|
||||
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :auth_url => 'http://localhost:5000/v2.0',
|
||||
:auth_region => 'RegionOne',
|
||||
:auth_user => 'ceilometer',
|
||||
:auth_password => 'password',
|
||||
:auth_tenant_name => 'services',
|
||||
:enabled => true,
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer-agent-compute' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'installs ceilometer-agent-compute package' do
|
||||
should contain_package('ceilometer-agent-compute').with(
|
||||
:ensure => 'installed',
|
||||
:name => platform_params[:agent_package_name],
|
||||
:before => 'Service[ceilometer-agent-compute]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'adds ceilometer user to libvirt group if required' do
|
||||
if platform_params[:libvirt_group]
|
||||
should contain_user('ceilometer').with_groups(/#{platform_params[:libvirt_group]}/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'ensures ceilometer-common is installed before the service' do
|
||||
should contain_package('ceilometer-common').with(
|
||||
:before => /Service\[ceilometer-agent-compute\]/
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer-agent-compute service' do
|
||||
should contain_service('ceilometer-agent-compute').with(
|
||||
:ensure => 'running',
|
||||
:name => platform_params[:agent_service_name],
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures authentication' do
|
||||
should contain_ceilometer_config('DEFAULT/os_auth_url').with_value('http://localhost:5000/v2.0')
|
||||
should contain_ceilometer_config('DEFAULT/os_auth_region').with_value('RegionOne')
|
||||
should contain_ceilometer_config('DEFAULT/os_username').with_value('ceilometer')
|
||||
should contain_ceilometer_config('DEFAULT/os_password').with_value('password')
|
||||
should contain_ceilometer_config('DEFAULT/os_tenant_name').with_value('services')
|
||||
end
|
||||
|
||||
it 'configures instance usage audit in nova' do
|
||||
should contain_nova_config('DEFAULT/instance_usage_audit').with_value('True')
|
||||
should contain_nova_config('DEFAULT/instance_usage_audit_period').with_value('hour')
|
||||
end
|
||||
|
||||
it 'configures nova notification driver' do
|
||||
should contain_file_line('nova-notification-driver-common').with(
|
||||
:line => 'notification_driver=nova.openstack.common.notifier.rpc_notifier',
|
||||
:path => '/etc/nova/nova.conf',
|
||||
:notify => 'Service[nova-compute]'
|
||||
)
|
||||
should contain_file_line('nova-notification-driver-ceilometer').with(
|
||||
:line => 'notification_driver=ceilometer.compute.nova_notifier',
|
||||
:path => '/etc/nova/nova.conf',
|
||||
:notify => 'Service[nova-compute]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :agent_package_name => 'ceilometer-agent-compute',
|
||||
:agent_service_name => 'ceilometer-agent-compute' }
|
||||
end
|
||||
|
||||
context 'on Ubuntu operating systems' do
|
||||
before do
|
||||
facts.merge!( :operatingsystem => 'Ubuntu' )
|
||||
platform_params.merge!( :libvirt_group => 'libvirtd' )
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-agent-compute'
|
||||
end
|
||||
|
||||
context 'on other operating systems' do
|
||||
before do
|
||||
platform_params.merge!( :libvirt_group => 'libvirt' )
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-agent-compute'
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :agent_package_name => 'openstack-ceilometer-compute',
|
||||
:agent_service_name => 'openstack-ceilometer-compute' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-agent-compute'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,107 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::api' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:keystone_host => '127.0.0.1',
|
||||
:keystone_port => '35357',
|
||||
:keystone_protocol => 'http',
|
||||
:keystone_user => 'ceilometer',
|
||||
:keystone_password => 'ceilometer-passw0rd',
|
||||
:keystone_tenant => 'services'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer-api' do
|
||||
|
||||
context 'without required parameter keystone_password' do
|
||||
before { params.delete(:keystone_password) }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'installs ceilometer-api package' do
|
||||
should contain_package('ceilometer-api').with(
|
||||
:ensure => 'installed',
|
||||
:name => platform_params[:api_package_name]
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer-api service' do
|
||||
should contain_service('ceilometer-api').with(
|
||||
:ensure => 'running',
|
||||
:name => platform_params[:api_service_name],
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => 'Class[Ceilometer::Db]',
|
||||
:subscribe => 'Exec[ceilometer-dbsync]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures keystone authentication middleware' do
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_host').with_value( params[:keystone_host] )
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_port').with_value( params[:keystone_port] )
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_protocol').with_value( params[:keystone_protocol] )
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_tenant_name').with_value( params[:keystone_tenant] )
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_user').with_value( params[:keystone_user] )
|
||||
should contain_ceilometer_config('keystone_authtoken/admin_password').with_value( params[:keystone_password] )
|
||||
should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_ensure('absent')
|
||||
end
|
||||
|
||||
context 'when specifying keystone_auth_admin_prefix' do
|
||||
describe 'with a correct value' do
|
||||
before { params['keystone_auth_admin_prefix'] = '/keystone/admin' }
|
||||
it { should contain_ceilometer_config('keystone_authtoken/auth_admin_prefix').with_value('/keystone/admin') }
|
||||
end
|
||||
|
||||
[
|
||||
'/keystone/',
|
||||
'keystone/',
|
||||
'keystone',
|
||||
'/keystone/admin/',
|
||||
'keystone/admin/',
|
||||
'keystone/admin'
|
||||
].each do |auth_admin_prefix|
|
||||
describe "with an incorrect value #{auth_admin_prefix}" do
|
||||
before { params['keystone_auth_admin_prefix'] = auth_admin_prefix }
|
||||
|
||||
it { expect { should contain_ceilomete_config('keystone_authtoken/auth_admin_prefix') }.to \
|
||||
raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :api_package_name => 'ceilometer-api',
|
||||
:api_service_name => 'ceilometer-api' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-api'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :api_package_name => 'openstack-ceilometer-api',
|
||||
:api_service_name => 'openstack-ceilometer-api' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-api'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,40 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::client' do
|
||||
|
||||
shared_examples_for 'ceilometer client' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'installs ceilometer client package' do
|
||||
should contain_package('python-ceilometerclient').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:client_package_name]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :client_package_name => 'python-ceilometerclient' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer client'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :client_package_name => 'python-ceilometerclient' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer client'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,58 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::collector' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer-collector' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'installs ceilometer-collector package' do
|
||||
should contain_package('ceilometer-collector').with(
|
||||
:ensure => 'installed',
|
||||
:name => platform_params[:collector_package_name]
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer-collector service' do
|
||||
should contain_service('ceilometer-collector').with(
|
||||
:ensure => 'running',
|
||||
:name => platform_params[:collector_service_name],
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:require => 'Class[Ceilometer::Db]',
|
||||
:subscribe => 'Exec[ceilometer-dbsync]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :collector_package_name => 'ceilometer-collector',
|
||||
:collector_service_name => 'ceilometer-collector' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-collector'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :collector_package_name => 'openstack-ceilometer-collector',
|
||||
:collector_service_name => 'openstack-ceilometer-collector' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer-collector'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,51 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::db::mysql' do
|
||||
|
||||
let :pre_condition do
|
||||
'include mysql::server'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :password => 's3cr3t',
|
||||
:dbname => 'ceilometer',
|
||||
:user => 'ceilometer',
|
||||
:host => 'localhost',
|
||||
:charset => 'latin1'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer mysql database' do
|
||||
|
||||
context 'when omiting the required parameter password' do
|
||||
before { params.delete(:password) }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
it 'creates a mysql database' do
|
||||
should contain_mysql__db( params[:dbname] ).with(
|
||||
:user => params[:user],
|
||||
:password => params[:password],
|
||||
:host => params[:host],
|
||||
:charset => params[:charset],
|
||||
:require => 'Class[Mysql::Config]'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer mysql database'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer mysql database'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,161 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:metering_secret => 'metering-s3cr3t',
|
||||
:package_ensure => 'present',
|
||||
:verbose => 'False',
|
||||
:debug => 'False',
|
||||
:rabbit_host => '127.0.0.1',
|
||||
:rabbit_port => 5672,
|
||||
:rabbit_userid => 'guest',
|
||||
:rabbit_password => '',
|
||||
:rabbit_virtualhost => '/',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer' do
|
||||
|
||||
context 'with rabbit_host parameter' do
|
||||
it_configures 'a ceilometer base installation'
|
||||
it_configures 'rabbit without HA support (with backward compatibility)'
|
||||
end
|
||||
|
||||
context 'with rabbit_hosts parameter' do
|
||||
context 'with one server' do
|
||||
before { params.merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) }
|
||||
it_configures 'a ceilometer base installation'
|
||||
it_configures 'rabbit without HA support (without backward compatibility)'
|
||||
end
|
||||
|
||||
context 'with multiple servers' do
|
||||
before { params.merge!( :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5672'] ) }
|
||||
it_configures 'a ceilometer base installation'
|
||||
it_configures 'rabbit with HA support'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'a ceilometer base installation' do
|
||||
|
||||
it { should include_class('ceilometer::params') }
|
||||
|
||||
it 'configures ceilometer group' do
|
||||
should contain_group('ceilometer').with(
|
||||
:name => 'ceilometer',
|
||||
:require => 'Package[ceilometer-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer user' do
|
||||
should contain_user('ceilometer').with(
|
||||
:name => 'ceilometer',
|
||||
:gid => 'ceilometer',
|
||||
:groups => ['nova'],
|
||||
:system => true,
|
||||
:require => 'Package[ceilometer-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer configuration folder' do
|
||||
should contain_file('/etc/ceilometer/').with(
|
||||
:ensure => 'directory',
|
||||
:owner => 'ceilometer',
|
||||
:group => 'ceilometer',
|
||||
:mode => '0750',
|
||||
:require => 'Package[ceilometer-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer configuration file' do
|
||||
should contain_file('/etc/ceilometer/ceilometer.conf').with(
|
||||
:owner => 'ceilometer',
|
||||
:group => 'ceilometer',
|
||||
:mode => '0640',
|
||||
:require => 'Package[ceilometer-common]'
|
||||
)
|
||||
end
|
||||
|
||||
it 'installs ceilometer common package' do
|
||||
should contain_package('ceilometer-common').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:common_package_name]
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures required metering_secret' do
|
||||
should contain_ceilometer_config('DEFAULT/metering_secret').with_value('metering-s3cr3t')
|
||||
end
|
||||
|
||||
context 'without the required metering_secret' do
|
||||
before { params.delete(:metering_secret) }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
it 'configures rabbit' do
|
||||
should contain_ceilometer_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
|
||||
should contain_ceilometer_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
|
||||
should contain_ceilometer_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
|
||||
end
|
||||
|
||||
it 'configures debug and verbose' do
|
||||
should contain_ceilometer_config('DEFAULT/debug').with_value( params[:debug] )
|
||||
should contain_ceilometer_config('DEFAULT/verbose').with_value( params[:verbose] )
|
||||
end
|
||||
|
||||
it 'fixes a bad value in ceilometer (glance_control_exchange)' do
|
||||
should contain_ceilometer_config('DEFAULT/glance_control_exchange').with_value('glance')
|
||||
end
|
||||
|
||||
it 'adds glance-notifications topic' do
|
||||
should contain_ceilometer_config('DEFAULT/notification_topics').with_value('notifications,glance_notifications')
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
|
||||
end
|
||||
|
||||
shared_examples_for 'rabbit without HA support (without backward compatibility)' do
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('false') }
|
||||
end
|
||||
|
||||
shared_examples_for 'rabbit with HA support' do
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_host').with_ensure('absent') }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_port').with_ensure('absent') }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
|
||||
it { should contain_ceilometer_config('DEFAULT/rabbit_ha_queues').with_value('true') }
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :common_package_name => 'ceilometer-common' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :common_package_name => 'openstack-ceilometer-common' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,79 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'ceilometer::keystone::auth' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:password => 'ceilometer-passw0rd',
|
||||
:email => 'ceilometer@localhost',
|
||||
:auth_name => 'ceilometer',
|
||||
:configure_endpoint => true,
|
||||
:service_type => 'metering',
|
||||
:public_address => '127.0.0.1',
|
||||
:admin_address => '127.0.0.1',
|
||||
:internal_address => '127.0.0.1',
|
||||
:port => '8777',
|
||||
:region => 'RegionOne',
|
||||
:tenant => 'services',
|
||||
:public_protocol => 'http'
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'ceilometer keystone auth' do
|
||||
|
||||
context 'without the required password parameter' do
|
||||
before { params.delete(:password) }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
it 'configures ceilometer user' do
|
||||
should contain_keystone_user( params[:auth_name] ).with(
|
||||
:ensure => 'present',
|
||||
:password => params[:password],
|
||||
:email => params[:email],
|
||||
:tenant => params[:tenant]
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer user roles' do
|
||||
should contain_keystone_user_role("#{params[:auth_name]}@#{params[:tenant]}").with(
|
||||
:ensure => 'present',
|
||||
:roles => ['admin','ResellerAdmin']
|
||||
)
|
||||
end
|
||||
|
||||
it 'configures ceilometer service' do
|
||||
should contain_keystone_service( params[:auth_name] ).with(
|
||||
:ensure => 'present',
|
||||
:type => params[:service_type],
|
||||
:description => 'Openstack Metering Service'
|
||||
)
|
||||
end
|
||||
|
||||
it 'configure ceilometer endpoints' do
|
||||
should contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}").with(
|
||||
:ensure => 'present',
|
||||
:public_url => "#{params[:public_protocol]}://#{params[:public_address]}:#{params[:port]}",
|
||||
:admin_url => "http://#{params[:admin_address]}:#{params[:port]}",
|
||||
:internal_url => "http://#{params[:internal_address]}:#{params[:port]}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer keystone auth'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'ceilometer keystone auth'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
[loggers]
|
||||
keys = root
|
||||
|
||||
[handlers]
|
||||
keys = root
|
||||
|
||||
[formatters]
|
||||
keys = default
|
||||
|
||||
[formatter_default]
|
||||
format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s
|
||||
|
||||
|
||||
[logger_root]
|
||||
level=NOTSET
|
||||
handlers = root
|
||||
propagate = 1
|
||||
|
||||
|
||||
[handler_root]
|
||||
class = StreamHandler
|
||||
level=NOTSET
|
||||
formatter = default
|
||||
args = (sys.stdout,)
|
|
@ -0,0 +1,63 @@
|
|||
[loggers]
|
||||
keys = root
|
||||
|
||||
[handlers]
|
||||
keys = production,devel,stderr
|
||||
|
||||
[formatters]
|
||||
keys = normal,debug
|
||||
|
||||
[logger_root]
|
||||
level = NOTSET
|
||||
handlers = production,devel,stderr
|
||||
propagate = 1
|
||||
|
||||
[formatter_debug]
|
||||
format = ceilometer-%(name)s %(levelname)s: %(module)s %(funcName)s %(message)s
|
||||
|
||||
[formatter_normal]
|
||||
format = ceilometer-%(name)s %(levelname)s: %(message)s
|
||||
|
||||
# logging info to LOG_<%= @syslog_log_facility %> with debug:<%= @debug %> and verbose:<%= @verbose %>
|
||||
[handler_production]
|
||||
class = handlers.SysLogHandler
|
||||
<% if @debug then -%>
|
||||
level = DEBUG
|
||||
formatter = debug
|
||||
<% elsif @verbose then -%>
|
||||
level = INFO
|
||||
formatter = normal
|
||||
<% else -%>
|
||||
level = <%= @syslog_log_level %>
|
||||
formatter = normal
|
||||
<% end -%>
|
||||
args = ('/dev/log', handlers.SysLogHandler.LOG_<%= @syslog_log_facility %>)
|
||||
|
||||
# TODO find out how it could be usefull and how it should be used
|
||||
[handler_stderr]
|
||||
class = StreamHandler
|
||||
<% if @debug then -%>
|
||||
level = DEBUG
|
||||
formatter = debug
|
||||
<% elsif @verbose then -%>
|
||||
level = INFO
|
||||
formatter = normal
|
||||
<% else -%>
|
||||
level = <%= @syslog_log_level %>
|
||||
formatter = normal
|
||||
<% end -%>
|
||||
args = (sys.stderr,)
|
||||
|
||||
[handler_devel]
|
||||
class = StreamHandler
|
||||
<% if @debug then -%>
|
||||
level = DEBUG
|
||||
formatter = debug
|
||||
<% elsif @verbose then -%>
|
||||
level = INFO
|
||||
formatter = normal
|
||||
<% else -%>
|
||||
level = <%= @syslog_log_level %>
|
||||
formatter = normal
|
||||
<% end -%>
|
||||
args = (sys.stdout,)
|
|
@ -0,0 +1,102 @@
|
|||
#
|
||||
# == Class: openstack::ceilometer
|
||||
#
|
||||
# Installs and configures Ceilometer
|
||||
#
|
||||
|
||||
class openstack::ceilometer (
|
||||
$rabbit_password,
|
||||
$keystone_password = 'ceilometer_pass',
|
||||
$metering_secret = 'ceilometer',
|
||||
$verbose = 'False',
|
||||
$use_syslog = 'False',
|
||||
$debug = 'False',
|
||||
$db_type = 'mysql',
|
||||
$db_host = 'localhost',
|
||||
$db_user = 'ceilometer',
|
||||
$db_password = 'ceilometer_pass',
|
||||
$db_dbname = 'ceilometer',
|
||||
$queue_provider = 'rabbitmq',
|
||||
$rabbit_host = '127.0.0.1',
|
||||
$rabbit_nodes = false,
|
||||
$rabbit_port = 5672,
|
||||
$rabbit_userid = 'guest',
|
||||
$rabbit_ha_virtual_ip = false,
|
||||
$qpid_host = '127.0.0.1',
|
||||
$qpid_nodes = false,
|
||||
$qpid_port = 5672,
|
||||
$qpid_userid = 'guest',
|
||||
$qpid_password = 'qpid_pw',
|
||||
$keystone_host = '127.0.0.1',
|
||||
$bind_host = '0.0.0.0',
|
||||
$bind_port = '8777',
|
||||
$on_controller = false,
|
||||
$on_compute = false,
|
||||
$ha_mode = false,
|
||||
) {
|
||||
|
||||
# Use VIP in the HA mode
|
||||
if $rabbit_ha_virtual_ip {
|
||||
$rabbit_host = $rabbit_ha_virtual_ip
|
||||
}
|
||||
|
||||
# Add the base ceilometer class & parameters
|
||||
# This class is required by ceilometer agents & api classes
|
||||
# The metering_secret parameter is mandatory
|
||||
class { '::ceilometer':
|
||||
package_ensure => $::openstack_version['ceilometer'],
|
||||
queue_provider => $queue_provider,
|
||||
rabbit_host => $rabbit_host,
|
||||
rabbit_port => $rabbit_port,
|
||||
rabbit_userid => $rabbit_userid,
|
||||
rabbit_password => $rabbit_password,
|
||||
qpid_host => $qpid_host,
|
||||
qpid_nodes => $qpid_nodes,
|
||||
qpid_port => $qpid_port,
|
||||
qpid_userid => $qpid_userid,
|
||||
qpid_password => $qpid_password,
|
||||
metering_secret => $metering_secret,
|
||||
verbose => $verbose,
|
||||
debug => $debug,
|
||||
use_syslog => $use_syslog,
|
||||
}
|
||||
|
||||
class { '::ceilometer::client': }
|
||||
|
||||
if ($on_controller) {
|
||||
# Configure the ceilometer database
|
||||
# Only needed if ceilometer::agent::central or ceilometer::api are declared
|
||||
class { '::ceilometer::db':
|
||||
database_connection => "${db_type}://${db_user}:${db_password}@${db_host}/${db_dbname}",
|
||||
}
|
||||
|
||||
# Install the ceilometer-api service
|
||||
# The keystone_password parameter is mandatory
|
||||
class { '::ceilometer::api':
|
||||
keystone_host => $keystone_host,
|
||||
keystone_password => $keystone_password,
|
||||
bind_host => $bind_host,
|
||||
bind_port => $bind_port,
|
||||
}
|
||||
|
||||
class { '::ceilometer::collector': }
|
||||
|
||||
class { '::ceilometer::agent::central':
|
||||
auth_host => $keystone_host,
|
||||
auth_password => $keystone_password,
|
||||
ha_mode => $ha_mode,
|
||||
}
|
||||
|
||||
#class { '::ceilometer::alarm::evaluator': }
|
||||
|
||||
#class { '::ceilometer::alarm::notifier': }
|
||||
}
|
||||
|
||||
if ($on_compute) {
|
||||
# Install compute agent
|
||||
class { 'ceilometer::agent::compute':
|
||||
auth_host => $keystone_host,
|
||||
auth_password => $keystone_password,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -97,6 +97,8 @@ class openstack::compute (
|
|||
# Quantum
|
||||
$quantum = false,
|
||||
$quantum_config = {},
|
||||
# Ceilometer
|
||||
$ceilometer_user_password = 'ceilometer_pass',
|
||||
# nova compute configuration parameters
|
||||
$verbose = false,
|
||||
$debug = false,
|
||||
|
@ -124,7 +126,9 @@ class openstack::compute (
|
|||
$nova_rate_limits = undef,
|
||||
$cinder_rate_limits = undef,
|
||||
$create_networks = false,
|
||||
$state_path = '/var/lib/nova'
|
||||
$state_path = '/var/lib/nova',
|
||||
$ceilometer = false,
|
||||
$ceilometer_metering_secret = "ceilometer",
|
||||
) {
|
||||
|
||||
#
|
||||
|
@ -248,6 +252,28 @@ class openstack::compute (
|
|||
content => "Host *\n StrictHostKeyChecking no\n UserKnownHostsFile=/dev/null\n",
|
||||
}
|
||||
|
||||
# configure ceilometer compute agent
|
||||
if ($ceilometer) {
|
||||
class { 'openstack::ceilometer':
|
||||
verbose => $verbose,
|
||||
debug => $debug,
|
||||
use_syslog => $use_syslog,
|
||||
rabbit_password => $rabbit_password,
|
||||
rabbit_userid => $rabbit_user,
|
||||
rabbit_port => $rabbit_port,
|
||||
rabbit_host => $rabbit_nodes[0],
|
||||
rabbit_ha_virtual_ip => $rabbit_ha_virtual_ip,
|
||||
queue_provider => $queue_provider,
|
||||
qpid_password => $qpid_password,
|
||||
qpid_userid => $qpid_user,
|
||||
qpid_nodes => $qpid_nodes,
|
||||
keystone_host => $service_endpoint,
|
||||
keystone_password => $ceilometer_user_password,
|
||||
on_compute => true,
|
||||
metering_secret => $ceilometer_metering_secret,
|
||||
}
|
||||
}
|
||||
|
||||
# if the compute node should be configured as a multi-host
|
||||
# compute installation
|
||||
if ! $quantum {
|
||||
|
@ -358,4 +384,4 @@ class openstack::compute (
|
|||
}
|
||||
}
|
||||
}
|
||||
# vim: set ts=2 sw=2 et :
|
||||
# vim: set ts=2 sw=2 et :
|
||||
|
|
|
@ -87,6 +87,11 @@ class openstack::controller (
|
|||
# Required Nova
|
||||
$nova_db_password = 'nova_pass',
|
||||
$nova_user_password = 'nova_pass',
|
||||
# Required Ceilometer
|
||||
$ceilometer = false,
|
||||
$ceilometer_db_password = 'ceilometer_pass',
|
||||
$ceilometer_user_password = 'ceilometer_pass',
|
||||
$ceilometer_metering_secret = 'ceilometer',
|
||||
# Required Horizon
|
||||
$secret_key = 'dummy_secret_key',
|
||||
# not sure if this works correctly
|
||||
|
@ -139,6 +144,9 @@ class openstack::controller (
|
|||
$nova_db_user = 'nova',
|
||||
$nova_db_dbname = 'nova',
|
||||
$purge_nova_config = false,
|
||||
# Ceilometer
|
||||
$ceilometer_db_user = 'ceilometer',
|
||||
$ceilometer_db_dbname = 'ceilometer',
|
||||
# Horizon
|
||||
$cache_server_ip = ['127.0.0.1'],
|
||||
$cache_server_port = '11211',
|
||||
|
@ -191,6 +199,9 @@ class openstack::controller (
|
|||
|
||||
# Ensure things are run in order
|
||||
Class['openstack::db::mysql'] -> Class['openstack::keystone']
|
||||
if ($ceilometer) {
|
||||
Class['openstack::db::mysql'] -> Class['openstack::ceilometer']
|
||||
}
|
||||
Class['openstack::db::mysql'] -> Class['openstack::glance']
|
||||
Class['openstack::db::mysql'] -> Class['openstack::nova::controller']
|
||||
Class['openstack::db::mysql'] -> Cinder_config <||>
|
||||
|
@ -220,6 +231,10 @@ class openstack::controller (
|
|||
nova_db_user => $nova_db_user,
|
||||
nova_db_password => $nova_db_password,
|
||||
nova_db_dbname => $nova_db_dbname,
|
||||
ceilometer => $ceilometer,
|
||||
ceilometer_db_user => $ceilometer_db_user,
|
||||
ceilometer_db_password => $ceilometer_db_password,
|
||||
ceilometer_db_dbname => $ceilometer_db_dbname,
|
||||
cinder => $cinder,
|
||||
cinder_db_user => $cinder_db_user,
|
||||
cinder_db_password => $cinder_db_password,
|
||||
|
@ -263,6 +278,8 @@ class openstack::controller (
|
|||
cinder_user_password => $cinder_user_password,
|
||||
quantum => $quantum,
|
||||
quantum_config => $quantum_config,
|
||||
ceilometer => $ceilometer,
|
||||
ceilometer_user_password => $ceilometer_user_password,
|
||||
bind_host => $api_bind_address,
|
||||
enabled => $enabled,
|
||||
package_ensure => $::openstack_keystone_version,
|
||||
|
@ -429,6 +446,35 @@ class openstack::controller (
|
|||
}
|
||||
}
|
||||
|
||||
######## Ceilometer ########
|
||||
|
||||
if ($ceilometer) {
|
||||
class { 'openstack::ceilometer':
|
||||
verbose => $verbose,
|
||||
debug => $debug,
|
||||
use_syslog => $use_syslog,
|
||||
db_type => $db_type,
|
||||
db_host => $db_host,
|
||||
db_user => $ceilometer_db_user,
|
||||
db_password => $ceilometer_db_password,
|
||||
db_dbname => $ceilometer_db_dbname,
|
||||
metering_secret => $ceilometer_metering_secret,
|
||||
rabbit_password => $rabbit_password,
|
||||
rabbit_userid => $rabbit_user,
|
||||
rabbit_host => $rabbit_nodes[0],
|
||||
rabbit_ha_virtual_ip => $rabbit_ha_virtual_ip,
|
||||
queue_provider => $queue_provider,
|
||||
qpid_password => $qpid_password,
|
||||
qpid_userid => $qpid_user,
|
||||
qpid_nodes => $qpid_nodes,
|
||||
keystone_host => $internal_address,
|
||||
keystone_password => $ceilometer_user_password,
|
||||
bind_host => $api_bind_address,
|
||||
ha_mode => $ha_mode,
|
||||
on_controller => true,
|
||||
}
|
||||
}
|
||||
|
||||
######## Horizon ########
|
||||
class { 'openstack::horizon':
|
||||
secret_key => $secret_key,
|
||||
|
|
|
@ -128,6 +128,10 @@ class openstack::controller_ha (
|
|||
$cinder_volume_group = 'cinder-volumes',
|
||||
$cinder_user_password = 'cinder_user_pass',
|
||||
$cinder_db_password = 'cinder_db_pass',
|
||||
$ceilometer = false,
|
||||
$ceilometer_db_password = 'ceilometer_pass',
|
||||
$ceilometer_user_password = 'ceilometer_pass',
|
||||
$ceilometer_metering_secret = 'ceilometer',
|
||||
$rabbit_node_ip_address = $internal_address,
|
||||
$horizon_use_ssl = false,
|
||||
$quantum_network_node = false,
|
||||
|
@ -219,6 +223,10 @@ class openstack::controller_ha (
|
|||
haproxy_service { 'swift': order => 96, port => 8080, virtual_ips => [$public_virtual_ip,$internal_virtual_ip], balancers => $swift_proxies }
|
||||
}
|
||||
|
||||
if $ceilometer {
|
||||
haproxy_service { 'ceilometer': order => 97, port => 8777, virtual_ips => [$public_virtual_ip, $internal_virtual_ip] }
|
||||
}
|
||||
|
||||
Haproxy_service<| |> ~> Exec['restart_haproxy']
|
||||
Haproxy_service<| |> -> Anchor['haproxy_done']
|
||||
Service<| title == 'haproxy' |> -> Anchor['haproxy_done']
|
||||
|
@ -317,6 +325,10 @@ class openstack::controller_ha (
|
|||
manage_volumes => $manage_volumes,
|
||||
nv_physical_volume => $nv_physical_volume,
|
||||
cinder_volume_group => $cinder_volume_group,
|
||||
ceilometer => $ceilometer,
|
||||
ceilometer_db_password => $ceilometer_db_password,
|
||||
ceilometer_user_password => $ceilometer_user_password,
|
||||
ceilometer_metering_secret => $ceilometer_metering_secret,
|
||||
# turn on SWIFT_ENABLED option for Horizon dashboard
|
||||
swift => $glance_backend ? { 'swift' => true, default => false },
|
||||
use_syslog => $use_syslog,
|
||||
|
|
|
@ -39,6 +39,7 @@ class openstack::db::mysql (
|
|||
$nova_db_password,
|
||||
$cinder_db_password,
|
||||
$neutron_db_password,
|
||||
$ceilometer_db_password,
|
||||
# MySQL
|
||||
$mysql_bind_address = '0.0.0.0',
|
||||
$mysql_account_security = true,
|
||||
|
@ -52,6 +53,10 @@ class openstack::db::mysql (
|
|||
$nova_db_user = 'nova',
|
||||
$nova_db_dbname = 'nova',
|
||||
$allowed_hosts = false,
|
||||
# Ceilometer
|
||||
$ceilometer = false,
|
||||
$ceilometer_db_user = 'ceilometer',
|
||||
$ceilometer_db_dbname = 'ceilometer',
|
||||
# Cinder
|
||||
$cinder = true,
|
||||
$cinder_db_user = 'cinder',
|
||||
|
@ -127,6 +132,16 @@ class openstack::db::mysql (
|
|||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
|
||||
# Create the Ceilometer db
|
||||
if ($ceilometer) {
|
||||
class { 'ceilometer::db::mysql':
|
||||
user => $ceilometer_db_user,
|
||||
password => $ceilometer_db_password,
|
||||
dbname => $ceilometer_db_dbname,
|
||||
allowed_hosts => $allowed_hosts,
|
||||
}
|
||||
}
|
||||
|
||||
# create cinder db
|
||||
if ($cinder) {
|
||||
class { 'cinder::db::mysql':
|
||||
|
|
|
@ -36,6 +36,7 @@ class openstack::firewall (
|
|||
$openvswitch_db_port = 58882,
|
||||
$libvirt_port = 16509,
|
||||
$nrpe_server_port = 5666,
|
||||
$ceilometer_port = 8777,
|
||||
) {
|
||||
|
||||
# file {"iptables":
|
||||
|
@ -206,6 +207,12 @@ class openstack::firewall (
|
|||
action => 'accept',
|
||||
}
|
||||
|
||||
firewall {'119 ceilometer':
|
||||
port => $ceilometer_port,
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
}
|
||||
|
||||
firewall { '333 accept gre':
|
||||
chain => 'PREROUTING',
|
||||
table => 'raw',
|
||||
|
|
|
@ -52,6 +52,7 @@ class openstack::keystone (
|
|||
$glance_user_password,
|
||||
$nova_user_password,
|
||||
$cinder_user_password,
|
||||
$ceilometer_user_password,
|
||||
$public_address,
|
||||
$db_type = 'mysql',
|
||||
$db_user = 'keystone',
|
||||
|
@ -75,9 +76,13 @@ class openstack::keystone (
|
|||
$quantum_public_address = false,
|
||||
$quantum_internal_address = false,
|
||||
$quantum_admin_address = false,
|
||||
$ceilometer_public_address = false,
|
||||
$ceilometer_internal_address = false,
|
||||
$ceilometer_admin_address = false,
|
||||
$glance = true,
|
||||
$nova = true,
|
||||
$cinder = true,
|
||||
$ceilometer = true,
|
||||
$quantum = true,
|
||||
$enabled = true,
|
||||
$package_ensure = present,
|
||||
|
@ -165,6 +170,21 @@ class openstack::keystone (
|
|||
} else {
|
||||
$quantum_admin_real = $admin_real
|
||||
}
|
||||
if($ceilometer_public_address) {
|
||||
$ceilometer_public_real = $ceilometer_public_address
|
||||
} else {
|
||||
$ceilometer_public_real = $public_address
|
||||
}
|
||||
if($ceilometer_internal_address) {
|
||||
$ceilometer_internal_real = $ceilometer_internal_address
|
||||
} else {
|
||||
$ceilometer_internal_real = $internal_real
|
||||
}
|
||||
if($ceilometer_admin_address) {
|
||||
$ceilometer_admin_real = $ceilometer_admin_address
|
||||
} else {
|
||||
$ceilometer_admin_real = $admin_real
|
||||
}
|
||||
|
||||
class { '::keystone':
|
||||
verbose => $verbose,
|
||||
|
@ -234,6 +254,14 @@ class openstack::keystone (
|
|||
internal_address => $quantum_internal_real,
|
||||
}
|
||||
}
|
||||
if $ceilometer {
|
||||
class { 'ceilometer::keystone::auth':
|
||||
password => $ceilometer_user_password,
|
||||
public_address => $ceilometer_public_real,
|
||||
admin_address => $ceilometer_admin_real,
|
||||
internal_address => $ceilometer_internal_real,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,17 @@ class osnailyfacter::cluster_ha {
|
|||
$heat_hash = $::fuel_settings['heat']
|
||||
}
|
||||
|
||||
if !$::fuel_settings['ceilometer'] {
|
||||
$ceilometer_hash = {
|
||||
enabled => false,
|
||||
db_password => 'ceilometer',
|
||||
user_password => 'ceilometer',
|
||||
metering_secret => 'ceilometer',
|
||||
}
|
||||
} else {
|
||||
$ceilometer_hash = $::fuel_settings['ceilometer']
|
||||
}
|
||||
|
||||
if $::fuel_settings['role'] == 'primary-controller' {
|
||||
package { 'cirros-testvm':
|
||||
ensure => "present"
|
||||
|
@ -261,6 +272,10 @@ class osnailyfacter::cluster_ha {
|
|||
cinder_db_password => $cinder_hash[db_password],
|
||||
cinder_volume_group => "cinder",
|
||||
manage_volumes => $manage_volumes,
|
||||
ceilometer => $ceilometer_hash[enabled],
|
||||
ceilometer_db_password => $ceilometer_hash[db_password],
|
||||
ceilometer_user_password => $ceilometer_hash[user_password],
|
||||
ceilometer_metering_secret => $ceilometer_hash[metering_secret],
|
||||
galera_nodes => $controller_nodes,
|
||||
custom_mysql_setup_class => $custom_mysql_setup_class,
|
||||
mysql_skip_name_resolve => true,
|
||||
|
@ -460,6 +475,9 @@ class osnailyfacter::cluster_ha {
|
|||
cinder_iscsi_bind_addr => $cinder_iscsi_bind_addr,
|
||||
cinder_user_password => $cinder_hash[user_password],
|
||||
cinder_db_password => $cinder_hash[db_password],
|
||||
ceilometer => $ceilometer_hash[enabled],
|
||||
ceilometer_metering_secret => $ceilometer_hash[metering_secret],
|
||||
ceilometer_user_password => $ceilometer_hash[user_password],
|
||||
db_host => $::fuel_settings['management_vip'],
|
||||
quantum => $::use_quantum,
|
||||
quantum_config => $quantum_config,
|
||||
|
|
|
@ -40,6 +40,17 @@ class osnailyfacter::cluster_simple {
|
|||
$heat_hash = $::fuel_settings['heat']
|
||||
}
|
||||
|
||||
if !$::fuel_settings['ceilometer'] {
|
||||
$ceilometer_hash = {
|
||||
enabled => false,
|
||||
db_password => 'ceilometer',
|
||||
user_password => 'ceilometer',
|
||||
metering_secret => 'ceilometer',
|
||||
}
|
||||
} else {
|
||||
$ceilometer_hash = $::fuel_settings['ceilometer']
|
||||
}
|
||||
|
||||
if $::fuel_settings['role'] == 'controller' {
|
||||
package { 'cirros-testvm':
|
||||
ensure => "present"
|
||||
|
@ -169,6 +180,10 @@ class osnailyfacter::cluster_simple {
|
|||
nova_db_password => $nova_hash[db_password],
|
||||
nova_user_password => $nova_hash[user_password],
|
||||
nova_rate_limits => $nova_rate_limits,
|
||||
ceilometer => $ceilometer_hash[enabled],
|
||||
ceilometer_db_password => $ceilometer_hash[db_password],
|
||||
ceilometer_user_password => $ceilometer_hash[user_password],
|
||||
ceilometer_metering_secret => $ceilometer_hash[metering_secret],
|
||||
queue_provider => $::queue_provider,
|
||||
rabbit_password => $rabbit_hash[password],
|
||||
rabbit_user => $rabbit_hash[user],
|
||||
|
@ -278,7 +293,6 @@ class osnailyfacter::cluster_simple {
|
|||
heat_db_password => $heat_hash['db_password'],
|
||||
}
|
||||
|
||||
|
||||
if $murano_hash['enabled'] {
|
||||
|
||||
class { 'murano' :
|
||||
|
@ -319,6 +333,9 @@ class osnailyfacter::cluster_simple {
|
|||
multi_host => $multi_host,
|
||||
sql_connection => $sql_connection,
|
||||
nova_user_password => $nova_hash[user_password],
|
||||
ceilometer => $ceilometer_hash[enabled],
|
||||
ceilometer_metering_secret => $ceilometer_hash[metering_secret],
|
||||
ceilometer_user_password => $ceilometer_hash[user_password],
|
||||
queue_provider => $::queue_provider,
|
||||
rabbit_nodes => [$controller_node_address],
|
||||
rabbit_password => $rabbit_hash[password],
|
||||
|
|
|
@ -287,6 +287,11 @@ if $debug =~ /(?i)(true|yes)/ {
|
|||
ensure => present,
|
||||
content => template("${module_name}/50-quantum.conf.erb"),
|
||||
}
|
||||
|
||||
file { "${rsyslog::params::rsyslog_d}51-ceilometer.conf":
|
||||
ensure => present,
|
||||
content => template("${module_name}/51-ceilometer.conf.erb"),
|
||||
}
|
||||
} #end if
|
||||
|
||||
file { "${rsyslog::params::rsyslog_d}02-ha.conf":
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# managed by puppet
|
||||
|
||||
:syslogtag, contains, "ceilometer" -/var/log/ceilometer-all.log
|
||||
:syslogtag, contains, "ceilometer" ~
|
Loading…
Reference in New Issue