Initial add of ceilometer recipes

These were migrated out of `openstack-compute` and into their
own cookbook.  This is an initial best-effort attempt.

Made the following changes, which differ from the recipes imported.
* Moved to openstack["metering"] attribute namespace.
* No longer performing source install.  This was done for folsom.
* No longer writing out an Apache virtualhost.  This was done to
  protect the folsom non-authenticated API endpoint.
* Templates write out as the ceilometer user/group vs nova.
* No longer including nova-common recipe.  It doesn't appear nova.conf
  is necessay (although I may be wrong).  The stackforge puppet manifests
  do not seem to do this [1].
* Added Strainerfile for testing.

  [1] https://github.com/stackforge/puppet-ceilometer).

bug 1187514
Change-Id: Ia97126e13e422037ad1f2c89debd9e4cdfa60b0a
This commit is contained in:
John Dewey 2013-07-25 20:30:12 -07:00
parent 8542c979f8
commit c9851501b7
27 changed files with 957 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.bundle/

4
Berksfile Normal file
View File

@ -0,0 +1,4 @@
metadata
cookbook "openstack-common",
git: "git://github.com/stackforge/cookbook-openstack-common.git"

36
Berksfile.lock Normal file
View File

@ -0,0 +1,36 @@
{
"sources": {
"openstack-metering": {
"path": "."
},
"openstack-common": {
"locked_version": "0.3.5",
"git": "git://github.com/stackforge/cookbook-openstack-common.git",
"ref": "4af229d56319b44945fe9e8ebd2ab2aa87b29c83"
},
"apt": {
"locked_version": "2.0.0"
},
"database": {
"locked_version": "1.4.0"
},
"mysql": {
"locked_version": "3.0.2"
},
"openssl": {
"locked_version": "1.0.2"
},
"build-essential": {
"locked_version": "1.4.0"
},
"postgresql": {
"locked_version": "3.0.2"
},
"aws": {
"locked_version": "0.101.2"
},
"xfs": {
"locked_version": "1.1.0"
}
}
}

9
Gemfile Normal file
View File

@ -0,0 +1,9 @@
source "https://rubygems.org"
gem "chef", "~> 11.4.4"
gem "json", "<= 1.7.7" # chef 11 dependency
gem "berkshelf", "~> 2.0.3"
gem "chefspec", "~> 1.3.0"
gem "foodcritic"
gem "strainer"
gem "tailor"

214
Gemfile.lock Normal file
View File

@ -0,0 +1,214 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.14)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.3.5)
akami (1.2.0)
gyoku (>= 0.4.0)
nokogiri (>= 1.4.0)
berkshelf (2.0.7)
activesupport (~> 3.2.0)
addressable (~> 2.3.4)
buff-shell_out (~> 0.1)
celluloid (>= 0.14.0)
chozo (>= 0.6.1)
faraday (>= 0.8.5)
hashie (>= 2.0.2)
minitar (~> 0.5.4)
rbzip2 (~> 0.2.0)
retryable (~> 1.3.3)
ridley (~> 1.2.1)
solve (>= 0.5.0)
thor (~> 0.18.0)
buff-extensions (0.5.0)
buff-ruby_engine (0.1.0)
buff-shell_out (0.1.0)
buff-ruby_engine (~> 0.1.0)
builder (3.2.2)
celluloid (0.14.1)
timers (>= 1.0.0)
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.4.4)
erubis
highline (>= 1.6.9)
json (>= 1.4.4, <= 1.7.7)
mixlib-authentication (>= 1.3.0)
mixlib-cli (~> 1.3.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1)
chefspec (1.3.1)
chef (>= 10.0)
erubis
fauxhai (>= 0.1.1, < 2.0)
minitest-chef-handler (>= 0.6.0)
rspec (~> 2.0)
chozo (0.6.1)
activesupport (>= 3.2.0)
hashie (>= 2.0.2)
multi_json (>= 1.3.0)
ci_reporter (1.9.0)
builder (>= 2.1.2)
diff-lcs (1.2.4)
erubis (2.7.0)
faraday (0.8.7)
multipart-post (~> 1.1)
fauxhai (1.1.1)
httparty
net-ssh
ohai
ffi (1.9.0)
foodcritic (2.2.0)
erubis
gherkin (~> 2.11.7)
nokogiri (~> 1.5.4)
treetop (~> 1.4.10)
yajl-ruby (~> 1.1.0)
gherkin (2.11.8)
multi_json (~> 1.3)
gssapi (1.0.3)
ffi (>= 1.0.1)
gyoku (1.0.0)
builder (>= 2.1.2)
hashie (2.0.5)
highline (1.6.19)
httparty (0.11.0)
multi_json (~> 1.0)
multi_xml (>= 0.5.2)
httpclient (2.2.0.2)
httpi (0.9.7)
rack
i18n (0.6.4)
ipaddress (0.8.0)
json (1.7.7)
little-plugger (1.1.3)
log_switch (0.4.0)
logging (1.6.2)
little-plugger (>= 1.1.3)
mime-types (1.23)
minitar (0.5.4)
minitest (4.7.5)
minitest-chef-handler (1.0.1)
chef
ci_reporter
minitest (~> 4.7.3)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.6.0)
mixlib-shellout (1.2.0)
multi_json (1.7.7)
multi_xml (0.5.4)
multipart-post (1.2.0)
net-http-persistent (2.9)
net-ssh (2.6.8)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
net-ssh-multi (1.1)
net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0)
nio4r (0.4.6)
nokogiri (1.5.10)
nori (1.1.5)
ohai (6.18.0)
ipaddress
mixlib-cli
mixlib-config
mixlib-log
mixlib-shellout
systemu
yajl-ruby
polyglot (0.3.3)
rack (1.5.2)
rbzip2 (0.2.0)
rest-client (1.6.7)
mime-types (>= 1.16)
retryable (1.3.3)
ridley (1.2.4)
addressable
buff-extensions (~> 0.3)
buff-shell_out (~> 0.1)
celluloid (~> 0.14.0)
celluloid-io (~> 0.14.0)
erubis
faraday (>= 0.8.4)
hashie (>= 2.0.2)
json (>= 1.7.7)
mixlib-authentication (>= 1.3.0)
net-http-persistent (>= 2.8)
net-ssh
retryable
solve (>= 0.4.4)
varia_model (~> 0.1)
winrm (~> 1.1.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.4)
rspec-expectations (2.14.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.1)
rubyntlm (0.1.1)
savon (0.9.5)
akami (~> 1.0)
builder (>= 2.1.2)
gyoku (>= 0.4.0)
httpi (~> 0.9)
nokogiri (>= 1.4.0)
nori (~> 1.0)
wasabi (~> 1.0)
solve (0.6.1)
strainer (3.0.5)
berkshelf (~> 2.0)
systemu (2.5.2)
tailor (1.2.1)
log_switch (>= 0.3.0)
term-ansicolor (>= 1.0.5)
text-table (>= 1.2.2)
term-ansicolor (1.2.2)
tins (~> 0.8)
text-table (1.2.3)
thor (0.18.1)
timers (1.1.0)
tins (0.8.3)
treetop (1.4.14)
polyglot
polyglot (>= 0.3.1)
uuidtools (2.1.4)
varia_model (0.1.1)
buff-extensions (~> 0.2)
hashie (>= 2.0.2)
wasabi (1.0.0)
nokogiri (>= 1.4.0)
winrm (1.1.2)
gssapi (~> 1.0.0)
httpclient (~> 2.2.0.2)
logging (~> 1.6.1)
nokogiri (~> 1.5.0)
rubyntlm (~> 0.1.1)
savon (= 0.9.5)
uuidtools (~> 2.1.2)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
berkshelf (~> 2.0.3)
chef (~> 11.4.4)
chefspec (~> 1.3.0)
foodcritic
json (<= 1.7.7)
strainer
tailor

View File

@ -1,7 +1,9 @@
Description
===========
Installs the OpenStack Metering service **Ceilometer** as part of the OpenStack reference deployment Chef for OpenStack. The http://github.com/mattray/chef-openstack-repo contains documentation for using this cookbook in the context of a full OpenStack deployment. Ceilometer is currently installed from packages.
Installs the OpenStack Metering service **Ceilometer** as part of the OpenStack
reference deployment Chef for OpenStack. Ceilometer is currently installed
from packages.
https://wiki.openstack.org/wiki/Ceilometer
@ -14,15 +16,41 @@ Cookbooks
Usage
=====
agent-central
----
- Installs agent central service.
agent-compute
----
- Installs agent compute service.
api
----
- Installs API service.
collector
----
- Installs nova network service.
common
----
- Common metering configuration.
Attributes
==========
Testing
=====
This cookbook is using [ChefSpec](https://github.com/acrmp/chefspec) for testing. Run the following before commiting. It will run your tests, and check for lint errors.
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
$ ./run_tests.bash
Tests are defined in Strainerfile.
To run tests:
$ bundle install # install gem dependencies
$ bundle exec berks install # install cookbook dependencies
$ bundle exec strainer test # run tests
License and Author
==================
@ -30,8 +58,11 @@ License and Author
| | |
|:---------------------|:---------------------------------------------------|
| **Author** | Matt Ray (<matt@opscode.com>) |
| **Author** | John Dewey (<jdewey@att.com>) |
| | |
| **Copyright** | Copyright (c) 2013, Opscode, Inc. |
| **Copyright** | Copyright (c) 2013, AT&T Services, Inc. |
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

5
Strainerfile Normal file
View File

@ -0,0 +1,5 @@
# Strainerfile
tailor: bundle exec tailor
knife test: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec

71
attributes/default.rb Normal file
View File

@ -0,0 +1,71 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: default
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
# The name of the Chef role that knows about the message queue server
# that Nova uses
default["openstack"]["metering"]["rabbit_server_chef_role"] = "os-ops-messaging"
# This user's password is stored in an encrypted databag
# and accessed with openstack-common cookbook library's
# user_password routine. You are expected to create
# the user, pass, vhost in a wrapper rabbitmq cookbook.
default["openstack"]["metering"]["rabbit"]["username"] = "guest"
default["openstack"]["metering"]["rabbit"]["vhost"] = "/"
default["openstack"]["metering"]["rabbit"]["port"] = 5672
default["openstack"]["metering"]["rabbit"]["host"] = "127.0.0.1"
default["openstack"]["metering"]["rabbit"]["ha"] = false
default["openstack"]["metering"]["conf_dir"] = "/etc/ceilometer"
default["openstack"]["metering"]["conf"] = ::File.join(node["openstack"]["metering"]["conf_dir"], "ceilometer.conf")
default["openstack"]["metering"]["db"]["username"] = "ceilometer"
default["openstack"]["metering"]["periodic_interval"] = 600
default["openstack"]["metering"]["syslog"]["use"] = false
default["openstack"]["metering"]["api"]["auth"]["cache_dir"] = "/var/cache/ceilometer/api"
default["openstack"]["metering"]["user"] = "ceilometer"
default["openstack"]["metering"]["group"] = "ceilometer"
case platform
when "suse" # :pragma-foodcritic: ~FC024 - won't fix this
default["openstack"]["metering"]["platform"] = {
"common_packages" => ["openstack-ceilometer"],
"agent_central_packages" => ["openstack-ceilometer-agent-central"],
"agent_central_service" => "openstack-ceilometer-agent-central",
"agent_compute_packages" => ["openstack-ceilometer-agent-compute"],
"agent_compute_service" => "openstack-ceilometer-agent-compute",
"api_packages" => ["openstack-ceilometer-api"],
"api_service" => "openstack-ceilometer-api",
"collector_packages" => ["openstack-ceilometer-collector"],
"collector_service" => "openstack-ceilometer-collector"
}
when "ubuntu"
default["openstack"]["metering"]["platform"] = {
"common_packages" => ["ceilometer-common"],
"agent_central_packages" => ["ceilometer-agent-central"],
"agent_central_service" => "ceilometer-agent-central",
"agent_compute_packages" => ["ceilometer-agent-compute"],
"agent_compute_service" => "ceilometer-agent-compute",
"api_packages" => ["ceilometer-api"],
"api_service" => "ceilometer-api",
"collector_packages" => ["ceilometer-collector"],
"collector_service" => "ceilometer-collector"
}
end

View File

@ -0,0 +1,3 @@
{
"context_is_admin": [["role:admin"]]
}

19
metadata.rb Normal file
View File

@ -0,0 +1,19 @@
name "openstack-metering"
maintainer "AT&T Services, Inc."
maintainer_email "cookbooks@lists.tfoundry.com"
license "Apache 2.0"
description "The OpenStack Metering service Ceilometer."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "7.0.0"
recipe "openstack-metering::agent-central", "Installs agent central service."
recipe "openstack-metering::agent-compute", "Installs agent compute service."
recipe "openstack-metering::api", "Installs API service."
recipe "openstack-metering::collector", "Installs nova network service."
recipe "openstack-metering::common", "Common metering configuration."
%w{ ubuntu suse }.each do |os|
supports os
end
depends "openstack-common", "~> 0.3.0"

30
recipes/agent-central.rb Normal file
View File

@ -0,0 +1,30 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: agent-central
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
include_recipe "openstack-metering::common"
platform = node["openstack"]["metering"]["platform"]
platform["agent_central_packages"].each do |pkg|
package pkg
end
service platform["agent_central_service"] do
action :start
end

30
recipes/agent-compute.rb Normal file
View File

@ -0,0 +1,30 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: agent-compute
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
include_recipe "openstack-metering::common"
platform = node["openstack"]["metering"]["platform"]
platform["agent_compute_packages"].each do |pkg|
package pkg
end
service platform["agent_compute_service"] do
action :start
end

37
recipes/api.rb Normal file
View File

@ -0,0 +1,37 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: api
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
include_recipe "openstack-metering::common"
directory ::File.dirname(node["openstack"]["metering"]["api"]["auth"]["cache_dir"]) do
owner node["openstack"]["metering"]["user"]
group node["openstack"]["metering"]["group"]
mode 00700
end
platform = node["openstack"]["metering"]["platform"]
platform["api_packages"].each do |pkg|
package pkg
end
service platform["api_service"] do
action :start
end

37
recipes/collector.rb Normal file
View File

@ -0,0 +1,37 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: collector
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
include_recipe "openstack-metering::common"
conf_switch = "--config-file #{node["openstack"]["metering"]["conf"]}"
execute "database migration" do
command "ceilometer-dbsync #{conf_switch}"
end
platform = node["openstack"]["metering"]["platform"]
platform["collector_packages"].each do |pkg|
package pkg
end
service platform["collector_service"] do
action :start
end

85
recipes/common.rb Normal file
View File

@ -0,0 +1,85 @@
#
# Cookbook Name:: openstack-metering
# Recipe:: common
#
# Copyright 2013, AT&T Services, Inc.
# Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# Copyright 2013, SUSE Linux GmbH
#
# 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.
#
class ::Chef::Recipe
include ::Openstack
end
if node["openstack"]["metering"]["syslog"]["use"]
include_recipe "openstack-common::logging"
end
platform = node["openstack"]["metering"]["platform"]
platform["common_packages"].each do |pkg|
package pkg
end
rabbit_pass = user_password node["openstack"]["metering"]["rabbit"]["username"]
db_info = db "metering"
db_user = node["openstack"]["metering"]["db"]["username"]
db_pass = db_password "openstack-metering"
db_query = db_info["db_type"] == "mysql" ? "?charset=utf8" : ""
db_uri = db_uri("metering", db_user, db_pass).to_s + db_query
service_user = node["openstack"]["metering"]["service_user"]
service_pass = service_password "openstack-compute"
service_tenant = node["openstack"]["metering"]["service_tenant_name"]
identity_endpoint = endpoint "identity-api"
image_endpoint = endpoint "image-api"
Chef::Log.debug("openstack-metering::common:service_user|#{service_user}")
Chef::Log.debug("openstack-metering::common:service_tenant|#{service_tenant}")
Chef::Log.debug("openstack-metering::common:identity_endpoint|#{identity_endpoint.to_s}")
directory node["openstack"]["metering"]["conf_dir"] do
owner node["openstack"]["metering"]["user"]
group node["openstack"]["metering"]["group"]
mode 00750
action :create
end
template node["openstack"]["metering"]["conf"] do
source "ceilometer.conf.erb"
owner node["openstack"]["metering"]["user"]
group node["openstack"]["metering"]["group"]
mode 00640
variables(
:auth_uri => ::URI.decode(identity_endpoint.to_s),
:database_connection => db_uri,
:image_endpoint => image_endpoint,
:identity_endpoint => identity_endpoint,
:rabbit_pass => rabbit_pass,
:service_pass => service_pass,
:service_tenant_name => service_tenant,
:service_user => service_user
)
end
cookbook_file "/etc/ceilometer/policy.json" do
source "policy.json"
mode 00640
owner node["openstack"]["metering"]["user"]
group node["openstack"]["metering"]["group"]
end

View File

@ -0,0 +1,19 @@
require_relative "spec_helper"
describe "openstack-metering::agent-central" do
before { metering_stubs }
describe "opensuse" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-metering::agent-central"
end
it "installs the agent-central package" do
expect(@chef_run).to install_package "openstack-ceilometer-agent-central"
end
it "starts the agent-central service" do
expect(@chef_run).to start_service "openstack-ceilometer-agent-central"
end
end
end

View File

@ -0,0 +1,21 @@
require_relative "spec_helper"
describe "openstack-metering::agent-central" do
before { metering_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-metering::agent-central"
end
expect_runs_common_recipe
it "installs the agent-central package" do
expect(@chef_run).to install_package "ceilometer-agent-central"
end
it "starts agent-central service" do
expect(@chef_run).to start_service("ceilometer-agent-central")
end
end
end

View File

@ -0,0 +1,19 @@
require_relative "spec_helper"
describe "openstack-metering::agent-compute" do
before { metering_stubs }
describe "opensuse" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-metering::agent-compute"
end
it "installs the agent-compute package" do
expect(@chef_run).to install_package "openstack-ceilometer-agent-compute"
end
it "starts the agent-compute service" do
expect(@chef_run).to start_service "openstack-ceilometer-agent-compute"
end
end
end

View File

@ -0,0 +1,21 @@
require_relative "spec_helper"
describe "openstack-metering::agent-compute" do
before { metering_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-metering::agent-compute"
end
expect_runs_common_recipe
it "installs the agent-compute package" do
expect(@chef_run).to install_package "ceilometer-agent-compute"
end
it "starts ceilometer-agent-compute service" do
expect(@chef_run).to start_service("ceilometer-agent-compute")
end
end
end

19
spec/api-opensuse_spec.rb Normal file
View File

@ -0,0 +1,19 @@
require_relative "spec_helper"
describe "openstack-metering::api" do
before { metering_stubs }
describe "opensuse" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-metering::api"
end
it "installs the api package" do
expect(@chef_run).to install_package("openstack-ceilometer-api")
end
it "starts api service" do
expect(@chef_run).to start_service("openstack-ceilometer-api")
end
end
end

35
spec/api_spec.rb Normal file
View File

@ -0,0 +1,35 @@
require_relative "spec_helper"
describe "openstack-metering::api" do
before { metering_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-metering::api"
end
expect_runs_common_recipe
describe "/var/cache/ceilometer" do
before do
@dir = @chef_run.directory "/var/cache/ceilometer"
end
it "has proper owner" do
expect(@dir).to be_owned_by "ceilometer", "ceilometer"
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "700"
end
end
it "starts api service" do
expect(@chef_run).to start_service("ceilometer-api")
end
it "starts api service" do
expect(@chef_run).to start_service("ceilometer-api")
end
end
end

View File

@ -0,0 +1,19 @@
require_relative "spec_helper"
describe "openstack-metering::collector" do
before { metering_stubs }
describe "opensuse" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-metering::collector"
end
it "installs the collector package" do
expect(@chef_run).to install_package "openstack-ceilometer-collector"
end
it "starts the collector service" do
expect(@chef_run).to start_service "openstack-ceilometer-collector"
end
end
end

22
spec/collector_spec.rb Normal file
View File

@ -0,0 +1,22 @@
require_relative "spec_helper"
describe "openstack-metering::collector" do
before { metering_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-metering::collector"
end
expect_runs_common_recipe
it "executes ceilometer dbsync" do
command = "ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf"
expect(@chef_run).to execute_command command
end
it "starts collector service" do
expect(@chef_run).to start_service("ceilometer-collector")
end
end
end

View File

@ -0,0 +1,15 @@
require_relative "spec_helper"
describe "openstack-metering::common" do
before { metering_stubs }
describe "opensuse" do
before do
@chef_run = ::ChefSpec::ChefRunner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-metering::common"
end
it "installs the common package" do
expect(@chef_run).to install_package "openstack-ceilometer"
end
end
end

88
spec/common_spec.rb Normal file
View File

@ -0,0 +1,88 @@
require_relative "spec_helper"
describe "openstack-metering::common" do
before { metering_stubs }
describe "ubuntu" do
before do
@chef_run = ::ChefSpec::ChefRunner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["metering"]["syslog"]["use"] = true
end
@chef_run.converge "openstack-metering::common"
end
it "runs logging recipe" do
expect(@chef_run).to include_recipe "openstack-common::logging"
end
it "installs the common package" do
expect(@chef_run).to install_package "ceilometer-common"
end
describe "/etc/ceilometer" do
before do
@dir = @chef_run.directory "/etc/ceilometer"
end
it "has proper owner" do
expect(@dir).to be_owned_by "ceilometer", "ceilometer"
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "750"
end
end
describe "/etc/ceilometer" do
before do
@file = @chef_run.template "/etc/ceilometer/ceilometer.conf"
end
it "has proper owner" do
expect(@file).to be_owned_by("ceilometer", "ceilometer")
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq("640")
end
it "has rabbit_user" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_userid = guest"
end
it "has rabbit_password" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_password = rabbit-pass"
end
it "has rabbit_port" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_port = 5672"
end
it "has rabbit_host" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_host = 127.0.0.1"
end
it "has rabbit_virtual_host" do
expect(@chef_run).to create_file_with_content @file.name,
"rabbit_virtual_host = /"
end
end
describe "/etc/ceilometer/policy.json" do
before do
@dir = @chef_run.cookbook_file "/etc/ceilometer/policy.json"
end
it "has proper owner" do
expect(@dir).to be_owned_by "ceilometer", "ceilometer"
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "640"
end
end
end
end

34
spec/spec_helper.rb Normal file
View File

@ -0,0 +1,34 @@
require "chefspec"
::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = {
:platform => "opensuse",
:version => "12.3",
:log_level => ::LOG_LEVEL
}
::REDHAT_OPTS = {
:platform => "redhat",
:version => "6.3",
:log_level => ::LOG_LEVEL
}
::UBUNTU_OPTS = {
:platform => "ubuntu",
:version => "12.04",
:log_level => ::LOG_LEVEL
}
def metering_stubs
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
::Chef::Recipe.any_instance.stub(:service_password).and_return String.new
::Chef::Recipe.any_instance.stub(:db_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).
with("guest").
and_return "rabbit-pass"
end
def expect_runs_common_recipe
it "runs common recipe" do
expect(@chef_run).to include_recipe "openstack-metering::common"
end
end

View File

@ -0,0 +1,30 @@
[DEFAULT]
os_auth_url = <%= @auth_uri %>
os_tenant_name = <%= @service_tenant_name %>
os_password = <%= @service_pass %>
os_username = <%= @service_user %>
policy_file = /etc/ceilometer/policy.json
database_connection = <%= @database_connection %>
rabbit_userid = <%= node["openstack"]["metering"]["rabbit"]["username"] %>
rabbit_password = <%= @rabbit_pass %>
rabbit_port = <%= node["openstack"]["metering"]["rabbit"]["port"] %>
rabbit_host = <%= node["openstack"]["metering"]["rabbit"]["host"] %>
rabbit_virtual_host = <%= node["openstack"]["metering"]["rabbit"]["vhost"] %>
verbose = True
notification_topics = notifications,glance_notifications
rpc_backend = ceilometer.openstack.common.rpc.impl_kombu
<% if node["openstack"]["metering"]["syslog"]["use"] %>
log_config = /etc/openstack/logging.conf
<% end %>
glance_registry_host = <%= @image_endpoint.host %>
periodic_interval = <%= node["openstack"]["metering"]["periodic_interval"] %>
[keystone_authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
auth_host = <%= @identity_endpoint.host %>
auth_port = <%= @identity_endpoint.port %>
auth_protocol = <%= @identity_endpoint.scheme %>
admin_tenant_name = <%= @service_tenant_name %>
admin_user = <%= @service_user %>
admin_password = <%= @service_pass %>
signing_dir = <%= node["openstack"]["metering"]["api"]["auth"]["cache_dir"] %>