Merge pull request #54 from jhtran/cron_configurable

cron minutes configurable as attribute
This commit is contained in:
John Dewey 2013-05-09 10:26:32 -07:00
commit 0c1238b952
5 changed files with 20 additions and 3 deletions

View File

@ -160,6 +160,7 @@ PLATFORMS
DEPENDENCIES
berkshelf (~> 1.4.0)
celluloid (= 0.13.0)
chef (~> 10.18.2)
chefspec (~> 1.0.0)
foodcritic (~> 2.1.0)

View File

@ -100,6 +100,7 @@ default["cinder"]["syslog"]["facility"] = "LOG_LOCAL2"
default["cinder"]["syslog"]["config_facility"] = "local2"
default["cinder"]["api"]["ratelimit"] = "True"
default["cinder"]["cron"]["minute"] = '00'
default["cinder"]["volume"]["state_path"] = "/var/lib/cinder"
default["cinder"]["volume"]["volume_driver"] = "cinder.volume.driver.ISCSIDriver"

View File

@ -61,9 +61,21 @@ cookbook_file "/usr/local/bin/cinder-volume-usage-audit" do
group "root"
end
# cronjob run every minute
cron "cinder-volume-usage-audit" do
command "/usr/local/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log 2>&1"
# run cronjob only on one node
cron_cmd = "/usr/local/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log 2>&1"
node_search = search(:node, "roles:openstack-volume-scheduler AND chef_environment:#{node.chef_environment}")
cron_node = node_search.collect{|a| a.name}.sort[0]
if node.name == cron_node
cron "cinder-volume-usage-audit" do
action :create
minute node["cinder"]["cron"]["minute"]
command cron_cmd
end
else
cron "cinder-volume-usage-audit" do
action :delete
command cron_cmd
end
end
template "/etc/cinder/cinder.conf" do

View File

@ -45,6 +45,7 @@ describe "cinder::scheduler" do
cmd = "/usr/local/bin/cinder-volume-usage-audit > " \
"/var/log/cinder/audit.log 2>&1"
expect(cron.command).to eq cmd
expect(cron.minute).to eq '00'
end
expect_creates_cinder_conf "service[cinder-scheduler]"

View File

@ -1,4 +1,5 @@
require "chefspec"
require 'ostruct'
::LOG_LEVEL = :fatal
::REDHAT_OPTS = {
@ -21,6 +22,7 @@ def cinder_stubs
::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(:service_password).and_return String.new
::Chef::Recipe.any_instance.stub(:search).and_return([OpenStruct.new(:name => 'fauxhai.local')])
end
def expect_runs_openstack_common_logging_recipe