From 899ec191c9eae39dbc010d330740145a7c24e1fd Mon Sep 17 00:00:00 2001 From: galstrom21 <jshepher@rackspace.com> Date: Thu, 24 Jul 2014 11:27:28 -0500 Subject: [PATCH] Normalizing this cookbook This cookbook needed to be brought up to the standard of the other cookbooks in the repo. * Adding .gitreview * Normalizing .rubocop.yml * Normalizing Gemfile * Normalizing metadata.rb * Normalizing .gitignore * Adding specs/ directory and spec_helper.rb * Fixed all rubocop errors Change-Id: Ica7c525aae5fbd5c441ce50cff36046c678046d6 Partial-Bug: 1348243 --- .gitignore | 21 +--- .gitreview | 4 + .rubocop.yml | 36 +++--- Gemfile | 14 +-- Gemfile.lock | 245 +++++++++++++++++++++++++++++++++++++ attributes/cephfs.rb | 2 + attributes/conf.rb | 2 + attributes/default.rb | 2 + attributes/mds.rb | 2 + attributes/mon.rb | 2 + attributes/osd.rb | 2 + attributes/radosgw.rb | 1 + attributes/repo.rb | 2 + libraries/default.rb | 8 +- metadata.rb | 22 ++-- providers/client.rb | 6 +- recipes/apt.rb | 1 + recipes/cephfs.rb | 1 + recipes/conf.rb | 6 +- recipes/default.rb | 1 + recipes/mds.rb | 11 +- recipes/mon.rb | 12 +- recipes/osd.rb | 7 +- recipes/radosgw.rb | 7 +- recipes/radosgw_apache2.rb | 3 +- recipes/repo.rb | 2 + recipes/rpm.rb | 2 + recipes/tgt.rb | 3 +- resources/client.rb | 12 +- spec/spec_helper.rb | 22 ++++ 30 files changed, 378 insertions(+), 83 deletions(-) create mode 100644 .gitreview create mode 100644 Gemfile.lock create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore index 351201e..6681a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,8 @@ -.vagrant -Berksfile.lock -*~ -*# -.#* -\#*# -.*.sw[a-z] -*.un~ -/cookbooks - -# Bundler -Gemfile.lock -bin/* -.bundle/* - +.bundle/ +.cookbooks/ .kitchen/ .kitchen.local.yml +.vagrant/ +.coverage/ +Berksfile.lock +Vagrantfile diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..fd65962 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cookbook-ceph.git diff --git a/.rubocop.yml b/.rubocop.yml index 21ecf52..f0f21bc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,28 +1,24 @@ AllCops: Includes: - - Berksfile + - metadata.rb - Gemfile - - Rakefile - - Thorfile - - Guardfile - Excludes: - - vendor/** + - attributes/** + - libraries/** + - providers/** + - recipes/** + - resources/** + - spec/** -ClassLength: - Enabled: false -Documentation: - Enabled: false Encoding: + Exclude: + - metadata.rb + - Gemfile + +NumericLiterals: Enabled: false -HashSyntax: - Enabled: false + LineLength: - Enabled: false -MethodLength: - Enabled: false -SignalException: - Enabled: false -TrailingComma: - Enabled: false + Enabled: False + WordArray: - Enabled: false + MinSize: 3 diff --git a/Gemfile b/Gemfile index 54e4a7b..9af33a8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,12 @@ source 'https://rubygems.org' -gem 'chef', '~> 11' -gem 'berkshelf', '~> 2.0.10' - -group :test do - gem 'foodcritic', '~> 3.0' - gem 'rubocop' -end +gem 'chef', '~> 11.8' +gem 'berkshelf', '~> 2.0.18' +gem 'chefspec', '~> 3.4.0' +gem 'rspec', '~> 2.14.1' +gem 'foodcritic', '~> 3.0.3' +gem 'strainer' +gem 'rubocop', '~> 0.18.1' group :integration do gem 'test-kitchen', '~> 1.1.1' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..f044045 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,245 @@ +GEM + remote: https://rubygems.org/ + specs: + activesupport (3.2.19) + i18n (~> 0.6, >= 0.6.4) + multi_json (~> 1.0) + addressable (2.3.6) + akami (1.2.2) + gyoku (>= 0.4.0) + nokogiri + ast (2.0.0) + berkshelf (2.0.18) + activesupport (~> 3.2.0) + addressable (~> 2.3.4) + buff-shell_out (~> 0.1) + chozo (>= 0.6.1) + faraday (~> 0.8.5) + hashie (~> 2.0) + minitar (~> 0.5.4) + rbzip2 (~> 0.2.0) + retryable (~> 1.3.3) + ridley (~> 1.7.0) + solve (~> 0.8.2) + thor (~> 0.18.0) + buff-config (0.4.0) + buff-extensions (~> 0.3) + varia_model (~> 0.1) + buff-extensions (0.5.0) + buff-ignore (1.1.1) + buff-platform (0.1.0) + buff-ruby_engine (0.1.0) + buff-shell_out (0.1.1) + buff-ruby_engine (~> 0.1.0) + builder (3.2.2) + celluloid (0.15.2) + timers (~> 1.1.0) + celluloid-io (0.15.0) + celluloid (>= 0.15.0) + nio4r (>= 0.5.0) + chef (11.12.8) + chef-zero (>= 2.0.2, < 2.1) + diff-lcs (~> 1.2, >= 1.2.4) + erubis (~> 2.7) + highline (~> 1.6, >= 1.6.9) + json (>= 1.4.4, <= 1.8.1) + mime-types (~> 1.16) + mixlib-authentication (~> 1.3) + mixlib-cli (~> 1.4) + mixlib-config (~> 2.0) + mixlib-log (~> 1.3) + mixlib-shellout (~> 1.4) + net-ssh (~> 2.6) + net-ssh-multi (~> 1.1) + ohai (~> 7.0.4) + pry (~> 0.9) + rest-client (>= 1.0.4, < 1.7.0) + yajl-ruby (~> 1.1) + chef-zero (2.0.2) + hashie (~> 2.0) + json + mixlib-log (~> 1.3) + rack + chefspec (3.4.0) + chef (~> 11.0) + fauxhai (~> 2.0) + rspec (~> 2.14) + chozo (0.6.1) + activesupport (>= 3.2.0) + hashie (>= 2.0.2) + multi_json (>= 1.3.0) + coderay (1.1.0) + diff-lcs (1.2.5) + erubis (2.7.0) + faraday (0.8.9) + multipart-post (~> 1.2.0) + fauxhai (2.2.0) + net-ssh + ohai + ffi (1.9.3) + foodcritic (3.0.3) + erubis + gherkin (~> 2.11.7) + nokogiri (~> 1.5.4) + rake + 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.1.1) + builder (>= 2.1.2) + hashie (2.1.2) + highline (1.6.21) + httpclient (2.4.0) + httpi (0.9.7) + rack + i18n (0.6.11) + ipaddress (0.8.0) + json (1.8.1) + kitchen-vagrant (0.15.0) + test-kitchen (~> 1.0) + little-plugger (1.1.3) + logging (1.8.2) + little-plugger (>= 1.1.3) + multi_json (>= 1.8.4) + method_source (0.8.2) + mime-types (1.25.1) + minitar (0.5.4) + mixlib-authentication (1.3.0) + mixlib-log + mixlib-cli (1.5.0) + mixlib-config (2.1.0) + mixlib-log (1.6.0) + mixlib-shellout (1.4.0) + multi_json (1.10.1) + multipart-post (1.2.0) + net-http-persistent (2.9.4) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) + net-ssh-gateway (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-multi (1.2.0) + net-ssh (>= 2.6.5) + net-ssh-gateway (>= 1.2.0) + nio4r (1.0.0) + nokogiri (1.5.11) + nori (1.1.5) + ohai (7.0.4) + ipaddress + mime-types (~> 1.16) + mixlib-cli + mixlib-config (~> 2.0) + mixlib-log + mixlib-shellout (~> 1.2) + systemu (~> 2.5.2) + yajl-ruby + parser (2.1.9) + ast (>= 1.1, < 3.0) + slop (~> 3.4, >= 3.4.5) + polyglot (0.3.5) + powerpack (0.0.9) + pry (0.10.0) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + rack (1.5.2) + rainbow (2.0.0) + rake (10.3.2) + rbzip2 (0.2.0) + rdoc (4.1.1) + json (~> 1.4) + rest-client (1.6.8) + mime-types (~> 1.16) + rdoc (>= 2.4.2) + retryable (1.3.5) + ridley (1.7.1) + addressable + buff-config (~> 0.2) + buff-extensions (~> 0.3) + buff-ignore (~> 1.1) + buff-shell_out (~> 0.1) + celluloid (~> 0.15) + celluloid-io (~> 0.15) + 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.8) + rspec-expectations (2.14.5) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.6) + rubocop (0.18.1) + json (>= 1.7.7, < 2) + parser (~> 2.1.3) + powerpack (~> 0.0.6) + rainbow (>= 1.99.1, < 3.0) + rubyntlm (0.1.1) + safe_yaml (0.9.7) + 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) + slop (3.6.0) + solve (0.8.2) + strainer (3.4.0) + berkshelf (>= 2.0, < 4.0) + buff-platform (~> 0.1) + systemu (2.5.2) + test-kitchen (1.1.1) + mixlib-shellout (~> 1.2) + net-scp (~> 1.1) + net-ssh (~> 2.7) + safe_yaml (~> 0.9) + thor (~> 0.18) + thor (0.18.1) + timers (1.1.0) + treetop (1.4.15) + polyglot + polyglot (>= 0.3.1) + uuidtools (2.1.4) + varia_model (0.3.2) + buff-extensions (~> 0.2) + hashie (>= 2.0.2) + wasabi (1.0.0) + nokogiri (>= 1.4.0) + winrm (1.1.3) + gssapi (~> 1.0.0) + httpclient (~> 2.2, >= 2.2.0.2) + logging (~> 1.6, >= 1.6.1) + nokogiri (~> 1.5) + rubyntlm (~> 0.1.1) + savon (= 0.9.5) + uuidtools (~> 2.1.2) + yajl-ruby (1.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + berkshelf (~> 2.0.18) + chef (~> 11.8) + chefspec (~> 3.4.0) + foodcritic (~> 3.0.3) + kitchen-vagrant (~> 0.14) + rspec (~> 2.14.1) + rubocop (~> 0.18.1) + strainer + test-kitchen (~> 1.1.1) diff --git a/attributes/cephfs.rb b/attributes/cephfs.rb index 1043a47..f29a740 100644 --- a/attributes/cephfs.rb +++ b/attributes/cephfs.rb @@ -1 +1,3 @@ +# encoding: UTF-8 + default['ceph']['cephfs_mount'] = '/ceph' diff --git a/attributes/conf.rb b/attributes/conf.rb index a2045c6..ce305f6 100644 --- a/attributes/conf.rb +++ b/attributes/conf.rb @@ -1,2 +1,4 @@ +# encoding: UTF-8 + default['ceph']['config'] = {} default['ceph']['config-sections'] = {} diff --git a/attributes/default.rb b/attributes/default.rb index 8d9a48e..512165e 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,2 +1,4 @@ +# encoding: UTF-8 + default['ceph']['install_debug'] = true default['ceph']['encrypted_data_bags'] = false diff --git a/attributes/mds.rb b/attributes/mds.rb index 8ab64d8..ace9e25 100644 --- a/attributes/mds.rb +++ b/attributes/mds.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + case node['platform'] when 'ubuntu' default['ceph']['mds']['init_style'] = 'upstart' diff --git a/attributes/mon.rb b/attributes/mon.rb index 6fad683..c3d1ffc 100644 --- a/attributes/mon.rb +++ b/attributes/mon.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + case node['platform'] when 'ubuntu' default['ceph']['mon']['init_style'] = 'upstart' diff --git a/attributes/osd.rb b/attributes/osd.rb index 48f32d2..3a81567 100644 --- a/attributes/osd.rb +++ b/attributes/osd.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + case node['platform'] when 'ubuntu' default['ceph']['osd']['init_style'] = 'upstart' diff --git a/attributes/radosgw.rb b/attributes/radosgw.rb index 9fa7517..7f9ad1b 100644 --- a/attributes/radosgw.rb +++ b/attributes/radosgw.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Cookbook Name:: ceph # Attributes:: radosgw diff --git a/attributes/repo.rb b/attributes/repo.rb index 93a4701..ca37704 100644 --- a/attributes/repo.rb +++ b/attributes/repo.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + default['ceph']['branch'] = 'stable' # Can be stable, testing or dev. # Major release version to install or gitbuilder branch default['ceph']['version'] = 'dumpling' diff --git a/libraries/default.rb b/libraries/default.rb index d02f7c4..d3f5663 100644 --- a/libraries/default.rb +++ b/libraries/default.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + require 'ipaddr' require 'json' @@ -5,7 +7,7 @@ def crowbar? !defined?(Chef::Recipe::Barclamp).nil? end -def get_mon_nodes(extra_search = nil) +def get_mon_nodes(extra_search = nil) # rubocop:disable MethodLength if crowbar? mon_roles = search(:role, 'name:crowbar-* AND run_list:role\[ceph-mon\]') unless mon_roles.empty? @@ -28,7 +30,7 @@ end # 1. We look if the network is IPv6 or IPv4 # 2. We look for a route matching the network # 3. We grab the IP and return it with the port -def find_node_ip_in_network(network, nodeish = nil) +def find_node_ip_in_network(network, nodeish = nil) # rubocop:disable MethodLength nodeish = node unless nodeish net = IPAddr.new(network) nodeish['network']['interfaces'].each do |iface, addrs| @@ -43,7 +45,7 @@ def find_node_ip_in_network(network, nodeish = nil) nil end -def mon_addresses +def mon_addresses # rubocop:disable MethodLength mon_ips = [] if File.exist?("/var/run/ceph/ceph-mon.#{node['hostname']}.asok") diff --git a/metadata.rb b/metadata.rb index 10a94dd..8242e49 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,12 +1,12 @@ -name 'ceph' -maintainer 'Kyle Bader' -maintainer_email 'kyle.bader@dreamhost.com' -license 'Apache 2.0' -description 'Installs/Configures the Ceph distributed filesystem' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '0.2.1' +name 'ceph' +maintainer 'Kyle Bader' +maintainer_email 'kyle.bader@dreamhost.com' +license 'Apache 2.0' +description 'Installs/Configures the Ceph distributed filesystem' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.2.1' -depends 'apache2', '>= 1.1.12' -depends 'apt' -depends 'yum', '>= 3.0' -depends 'yum-epel' +depends 'apache2', '>= 1.1.12' +depends 'apt' +depends 'yum', '>= 3.0' +depends 'yum-epel' diff --git a/providers/client.rb b/providers/client.rb index becada6..5097ad2 100644 --- a/providers/client.rb +++ b/providers/client.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + use_inline_resources def whyrun_supported? @@ -28,7 +30,7 @@ def load_current_resource @current_resource.as_keyring(@new_resource.as_keyring) @current_resource.keyname(@new_resource.keyname || "client.#{current_resource.name}.#{node['hostname']}") @current_resource.caps(get_caps(@current_resource.keyname)) - default_filename = "/etc/ceph/ceph.client.#{@new_resource.name}.#{node['hostname']}.#{@new_resource.as_keyring ? "keyring" : "secret"}" + default_filename = "/etc/ceph/ceph.client.#{@new_resource.name}.#{node['hostname']}.#{@new_resource.as_keyring ? 'keyring' : 'secret'}" @current_resource.filename(@new_resource.filename || default_filename) @current_resource.key(get_new_key(@current_resource.keyname)) @current_resource.caps_match = true if @current_resource.caps == @new_resource.caps @@ -51,7 +53,7 @@ def get_caps(keyname) caps end -def auth_set_key(keyname, caps) +def auth_set_key(keyname, caps) # rubocop:disable MethodLength # find the monitor secret mon_secret = '' mons = get_mon_nodes diff --git a/recipes/apt.rb b/recipes/apt.rb index f593cad..bb6e505 100644 --- a/recipes/apt.rb +++ b/recipes/apt.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 include_recipe 'apt' diff --git a/recipes/cephfs.rb b/recipes/cephfs.rb index 0d6e4b6..a4db982 100644 --- a/recipes/cephfs.rb +++ b/recipes/cephfs.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph diff --git a/recipes/conf.rb b/recipes/conf.rb index f735260..b133b9d 100644 --- a/recipes/conf.rb +++ b/recipes/conf.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + fail 'fsid must be set in config' if node['ceph']['config']['fsid'].nil? fail 'mon_initial_members must be set in config' if node['ceph']['config']['mon_initial_members'].nil? @@ -11,8 +13,8 @@ end template '/etc/ceph/ceph.conf' do source 'ceph.conf.erb' variables( - :mon_addresses => mon_addresses, - :is_rgw => node['ceph']['is_radosgw'] + mon_addresses: mon_addresses, + is_rgw: node['ceph']['is_radosgw'] ) mode '0644' end diff --git a/recipes/default.rb b/recipes/default.rb index 7d1eb57..d468569 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph diff --git a/recipes/mds.rb b/recipes/mds.rb index 658de9d..dccb8bd 100644 --- a/recipes/mds.rb +++ b/recipes/mds.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph @@ -22,7 +23,7 @@ include_recipe 'ceph::conf' cluster = 'ceph' -directory "/var/lib/ceph/mds/#{cluster}-#{node["hostname"]}" do +directory "/var/lib/ceph/mds/#{cluster}-#{node['hostname']}" do owner 'root' group 'root' mode 00755 @@ -32,7 +33,7 @@ end ruby_block 'create mds client key' do block do - cmd = "ceph auth get-or-create mds.#{node['hostname']} osd 'allow *' mon 'allow rwx' --name mon. --key='#{node["ceph"]["monitor-secret"]}'" + cmd = "ceph auth get-or-create mds.#{node['hostname']} osd 'allow *' mon 'allow rwx' --name mon. --key='#{node['ceph']['monitor-secret']}'" keyring = Mixlib::ShellOut.new(cmd).run_command.stdout keyfile = File.new("/var/lib/ceph/mds/#{cluster}-#{node['hostname']}/keyring", 'w') @@ -41,7 +42,7 @@ ruby_block 'create mds client key' do end end -file "/var/lib/ceph/mds/#{cluster}-#{node["hostname"]}/done" do +file "/var/lib/ceph/mds/#{cluster}-#{node['hostname']}/done" do owner 'root' group 'root' mode 00644 @@ -55,7 +56,7 @@ when 'upstart' else filename = 'sysvinit' end -file "/var/lib/ceph/mds/#{cluster}-#{node["hostname"]}/#{filename}" do +file "/var/lib/ceph/mds/#{cluster}-#{node['hostname']}/#{filename}" do owner 'root' group 'root' mode 00644 @@ -70,5 +71,5 @@ service 'ceph_mds' do service_name 'ceph' end action [:enable, :start] - supports :restart => true + supports restart: true end diff --git a/recipes/mon.rb b/recipes/mon.rb index d899107..c1e31f2 100644 --- a/recipes/mon.rb +++ b/recipes/mon.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 +# # This recipe creates a monitor cluster # # You should never change the mon default path or @@ -29,7 +31,7 @@ directory '/var/run/ceph' do action :create end -directory "/var/lib/ceph/mon/ceph-#{node["hostname"]}" do +directory "/var/lib/ceph/mon/ceph-#{node['hostname']}" do owner 'root' group 'root' mode 00755 @@ -40,7 +42,7 @@ end # TODO: cluster name cluster = 'ceph' -unless File.exist?("/var/lib/ceph/mon/ceph-#{node["hostname"]}/done") +unless File.exist?("/var/lib/ceph/mon/ceph-#{node['hostname']}/done") keyring = "#{Chef::Config[:file_cache_path]}/#{cluster}-#{node['hostname']}.mon.keyring" if node['ceph']['encrypted_data_bags'] @@ -62,7 +64,7 @@ unless File.exist?("/var/lib/ceph/mon/ceph-#{node["hostname"]}/done") ruby_block 'finalise' do block do ['done', service_type].each do |ack| - ::File.open("/var/lib/ceph/mon/ceph-#{node["hostname"]}/#{ack}", 'w').close + ::File.open("/var/lib/ceph/mon/ceph-#{node['hostname']}/#{ack}", 'w').close end end end @@ -75,7 +77,7 @@ if service_type == 'upstart' end service 'ceph-mon-all' do provider Chef::Provider::Service::Upstart - supports :status => true + supports status: true action [:enable, :start] end end @@ -88,7 +90,7 @@ service 'ceph_mon' do else service_name 'ceph' end - supports :restart => true, :status => true + supports restart: true, status: true action [:enable, :start] end diff --git a/recipes/osd.rb b/recipes/osd.rb index 5c35bca..259e998 100644 --- a/recipes/osd.rb +++ b/recipes/osd.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph @@ -70,7 +71,7 @@ execute 'format as keyring' do end if crowbar? - node['crowbar']['disks'].each do |disk, data| + node['crowbar']['disks'].each do |disk, _data| execute "ceph-disk-prepare #{disk}" do command "ceph-disk-prepare /dev/#{disk}" only_if { node['crowbar']['disks'][disk]['usage'] == 'Storage' } @@ -102,7 +103,7 @@ else if !node['ceph']['osd_devices'].nil? devices = node['ceph']['osd_devices'] - devices = Hash[(0...devices.size).zip devices] unless devices.kind_of? Hash + devices = Hash[(0...devices.size).zip devices] unless devices.is_a? Hash devices.each do |index, osd_device| unless osd_device['status'].nil? @@ -150,7 +151,7 @@ else service_name 'ceph' end action [:enable, :start] - supports :restart => true + supports restart: true end else Log.info('node["ceph"]["osd_devices"] empty') diff --git a/recipes/radosgw.rb b/recipes/radosgw.rb index 85e5d6a..f32d7c7 100644 --- a/recipes/radosgw.rb +++ b/recipes/radosgw.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph @@ -45,9 +46,9 @@ end include_recipe 'ceph::conf' -if !::File.exists?("/var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']}/done") +if !::File.exist?("/var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']}/done") if node['ceph']['radosgw']['webserver_companion'] - include_recipe "ceph::radosgw_#{node["ceph"]["radosgw"]["webserver_companion"]}" + include_recipe "ceph::radosgw_#{node['ceph']['radosgw']['webserver_companion']}" end ceph_client 'radosgw' do @@ -70,7 +71,7 @@ if !::File.exists?("/var/lib/ceph/radosgw/ceph-radosgw.#{node['hostname']}/done" service_name 'ceph-radosgw' end end - supports :restart => true + supports restart: true action [:enable, :start] end else diff --git a/recipes/radosgw_apache2.rb b/recipes/radosgw_apache2.rb index b2694d9..ff7e818 100644 --- a/recipes/radosgw_apache2.rb +++ b/recipes/radosgw_apache2.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph @@ -94,6 +95,6 @@ template '/var/www/s3gw.fcgi' do group 'root' mode '0755' variables( - :ceph_rgw_client => "client.radosgw.#{node['hostname']}" + ceph_rgw_client: "client.radosgw.#{node['hostname']}" ) end diff --git a/recipes/repo.rb b/recipes/repo.rb index 986355a..5ac2250 100644 --- a/recipes/repo.rb +++ b/recipes/repo.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + case node['platform_family'] when 'debian' include_recipe 'ceph::apt' diff --git a/recipes/rpm.rb b/recipes/rpm.rb index 14c899c..2b4b468 100644 --- a/recipes/rpm.rb +++ b/recipes/rpm.rb @@ -1,3 +1,5 @@ +# encoding: UTF-8 + platform_family = node['platform_family'] case platform_family diff --git a/recipes/tgt.rb b/recipes/tgt.rb index eb353e9..6bdf27f 100644 --- a/recipes/tgt.rb +++ b/recipes/tgt.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Author:: Kyle Bader <kyle.bader@dreamhost.com> # Cookbook Name:: ceph @@ -46,6 +47,6 @@ service 'tgt' do else service_name 'tgt' end - supports :restart => true + supports restart: true action [:enable, :start] end diff --git a/resources/client.rb b/resources/client.rb index e8af62a..30db7ac 100644 --- a/resources/client.rb +++ b/resources/client.rb @@ -1,19 +1,21 @@ +# encoding: UTF-8 + actions :add default_action :add -attribute :name, :kind_of => String, :name_attribute => true -attribute :caps, :kind_of => Hash, :default => { 'mon' => 'allow r', 'osd' => 'allow r' } +attribute :name, kind_of: String, name_attribute: true +attribute :caps, kind_of: Hash, default: { 'mon' => 'allow r', 'osd' => 'allow r' } # Whether to store the secret in a keyring file or a plain secret file -attribute :as_keyring, :kind_of => [TrueClass, FalseClass], :default => true +attribute :as_keyring, kind_of: [TrueClass, FalseClass], default: true # what the key should be called in the ceph cluster # defaults to client.#{name}.#{hostname} -attribute :keyname, :kind_of => String +attribute :keyname, kind_of: String # where the key should be saved # defaults to /etc/ceph/ceph.client.#{name}.#{hostname}.keyring if as_keyring # defaults to /etc/ceph/ceph.client.#{name}.#{hostname}.secret if not as_keyring -attribute :filename, :kind_of => String +attribute :filename, kind_of: String attr_accessor :key, :caps_match diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2226bbe --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,22 @@ +# encoding: UTF-8 +require 'chefspec' +require 'chefspec/berkshelf' + +ChefSpec::Coverage.start! { add_filter 'ceph' } + +LOG_LEVEL = :fatal +SUSE_OPTS = { + platform: 'suse', + version: '11.3', + log_level: LOG_LEVEL +} +REDHAT_OPTS = { + platform: 'redhat', + version: '6.5', + log_level: LOG_LEVEL +} +UBUNTU_OPTS = { + platform: 'ubuntu', + version: '12.04', + log_level: LOG_LEVEL +}