From f7fe1e574407771ea515b96262cb295de5aea37a Mon Sep 17 00:00:00 2001 From: Craig Bryant Date: Wed, 16 Jul 2014 17:50:16 -0600 Subject: [PATCH] Get initial build to work. Add .gitreview, Gemfile, .rubocop.yml, Berksfile, Strainerfile Fixed style and lint errors. Added empty unit test so chef-unit passes until we get real unit tests Change-Id: I8f2e48782a5289c82b0d4fc147d95f637be046c6 --- .gitreview | 4 ++++ .rubocop.yml | 24 ++++++++++++++++++++++++ Berksfile | 1 + Gemfile | 11 +++++++++++ Strainerfile | 5 +++++ attributes/default.rb | 6 ++++-- metadata.rb | 14 ++++++++------ recipes/default.rb | 6 ++++-- recipes/plugin_cfg.rb | 19 ++++++++++--------- spec/empty.rb | 2 ++ 10 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 .gitreview create mode 100644 .rubocop.yml create mode 100644 Berksfile create mode 100644 Gemfile create mode 100644 Strainerfile create mode 100644 spec/empty.rb diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..99f7417 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cookbook-monasca-agent diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..5500e6d --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,24 @@ +AllCops: + Includes: + - metadata.rb + - Gemfile + - attributes/** + - libraries/** + - providers/** + - recipes/** + - resources/** + - spec/** + +Encoding: + Exclude: + - metadata.rb + - Gemfile + +NumericLiterals: + Enabled: false + +LineLength: + Enabled: false + +WordArray: + MinSize: 3 diff --git a/Berksfile b/Berksfile new file mode 100644 index 0000000..850a120 --- /dev/null +++ b/Berksfile @@ -0,0 +1 @@ +metadata diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..eeb359d --- /dev/null +++ b/Gemfile @@ -0,0 +1,11 @@ +source 'https://rubygems.org' + +gem 'chef', '~> 11.8' +gem 'json', '<= 1.7.7' # chef 11 dependency +gem 'berkshelf', '~> 2.0.18' +gem 'hashie', '~> 2.0' +gem 'chefspec', '~> 3.4.0' +gem 'rspec', '~> 2.14.1' +gem 'foodcritic', '~> 3.0.3' +gem 'strainer' +gem 'rubocop', '~> 0.18.1' diff --git a/Strainerfile b/Strainerfile new file mode 100644 index 0000000..cf2ff52 --- /dev/null +++ b/Strainerfile @@ -0,0 +1,5 @@ +# Strainerfile +rubocop: rubocop $SANDBOX/$COOKBOOK +knife test: knife cookbook test $COOKBOOK +foodcritic: foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK +chefspec: rspec $SANDBOX/$COOKBOOK/spec diff --git a/attributes/default.rb b/attributes/default.rb index 8a14234..99e592a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,2 +1,4 @@ -default['mon_agent']['data_bag'] = "mon_agent" -default['mon_agent']['plugin'] = {} +# encoding: UTF-8# +# +default[:mon_agent][:data_bag] = 'mon_agent' +default[:mon_agent][:plugin] = {} diff --git a/metadata.rb b/metadata.rb index d57502e..2f14a20 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,8 +1,10 @@ -name "mon_agent" -maintainer "HP_Cloud_Monitoring" -maintainer_email "hpcs-mon@hp.com" -description "Installs/Configures mon-agent components" +# encoding: UTF-8# +# +name 'mon_agent' +maintainer 'HP_Cloud_Monitoring' +maintainer_email 'hpcs-mon@hp.com' +description 'Installs/Configures mon-agent components' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "1.1.1" +version '1.1.1' depends 'python' -recipe "mon_api::default", "Default" +recipe 'mon_api::default', 'Default' diff --git a/recipes/default.rb b/recipes/default.rb index a1b3f71..7318bb8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,4 +1,6 @@ -include_recipe "python" +# encoding: UTF-8# +# +include_recipe 'python' # Pre-reqs that when installed by os package avoid compilation by pip %w[python-pymongo python-yaml supervisor sysstat].each do |pkg_name| @@ -15,7 +17,7 @@ end python_pip 'mon-agent' do action :install - notifies :run, "execute[mon-setup]" + notifies :run, 'execute[mon-setup]' end include_recipe 'mon_agent::plugin_cfg' diff --git a/recipes/plugin_cfg.rb b/recipes/plugin_cfg.rb index 82b9eb7..646c461 100644 --- a/recipes/plugin_cfg.rb +++ b/recipes/plugin_cfg.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8# # # Cookbook Name:: mon_agent # Recipe:: plugin_cfg @@ -6,25 +7,25 @@ # Load nagios-plugins package if it's needed package 'nagios-plugins-basic' do action :install - only_if { node[:mon_agent][:plugin].has_key?(:nagios_wrapper) } + only_if { node[:mon_agent][:plugin].key?(:nagios_wrapper) } end # Configures the plugin yaml files based on node[:mon_agent][:plugin] # attributes node[:mon_agent][:plugin].each_key do |plugin| - if not node[:mon_agent][:plugin][plugin].has_key?(:init_config) - node[:mon_agent][:plugin][plugin][:init_config] = {} + unless node[:mon_agent][:plugin][plugin].key?(:init_config) + node.normal[:mon_agent][:plugin][plugin][:init_config] = {} end template "/etc/mon-agent/conf.d/#{plugin}.yaml" do - source "plugin_yaml.erb" + source 'plugin_yaml.erb' action :create - owner node['mon_agent']['owner'] - group node['mon_agent']['group'] + owner node[:mon_agent][:owner] + group node[:mon_agent][:group] mode 0644 variables( - :init_config => node[:mon_agent][:plugin][plugin][:init_config], - :instances => node[:mon_agent][:plugin][plugin][:instances] + init_config: node[:mon_agent][:plugin][plugin][:init_config], + instances: node[:mon_agent][:plugin][plugin][:instances] ) - notifies :run, "execute[mon-setup]" + notifies :run, 'execute[mon-setup]' end end diff --git a/spec/empty.rb b/spec/empty.rb new file mode 100644 index 0000000..fc2f6d6 --- /dev/null +++ b/spec/empty.rb @@ -0,0 +1,2 @@ +# encoding: UTF-8 +# No unit tests at this time.