summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ray <matthewhray@gmail.com>2014-01-15 23:12:39 -0600
committerMatt Ray <matthewhray@gmail.com>2014-01-17 15:35:20 -0600
commit60e37c5eb057238122be61ec608eb72ba3d229b0 (patch)
treee41b0ab3cd5c656667f08f2ae75a15b7583a2f9c
parentdf36ef89be830a53fdcb3b6df2ea1bdba988a7e8 (diff)
Unified Rubocop cleanups under single file.
Consolidate all the .rubocop.yml into a single file, finished out cleanups for all the Ruby files. Change-Id: I92d5983724d5d0185cd25bea6a0f46657a6c05d4 Addresses: blueprint rubocop-for-block-storage
Notes
Notes (review): Verified+2: Jenkins Approved+1: craigtracey <craigtracey@gmail.com> Code-Review+2: Jesse Nelson <spheromak@gmail.com> Submitted-by: Jenkins Submitted-at: Sat, 18 Jan 2014 04:47:05 +0000 Reviewed-on: https://review.openstack.org/67008 Project: stackforge/cookbook-openstack-block-storage Branch: refs/heads/master
-rw-r--r--.rubocop.yml14
-rw-r--r--.tailor25
-rw-r--r--Berksfile.lock16
-rw-r--r--Gemfile1
-rw-r--r--Strainerfile8
-rw-r--r--TESTING.md9
-rw-r--r--attributes/.rubocop.yml7
-rw-r--r--attributes/default.rb10
-rw-r--r--metadata.rb1
-rw-r--r--recipes/.rubocop-todo.yml15
-rw-r--r--recipes/.rubocop.yml3
-rw-r--r--recipes/api.rb64
-rw-r--r--recipes/cinder-common.rb59
-rw-r--r--recipes/identity_registration.rb44
-rw-r--r--recipes/scheduler.rb40
-rw-r--r--recipes/volume.rb110
-rw-r--r--spec/.rubocop-todo.yml17
-rw-r--r--spec/.rubocop.yml3
-rw-r--r--spec/api-opensuse_spec.rb34
-rw-r--r--spec/api-redhat_spec.rb38
-rw-r--r--spec/api_spec.rb130
-rw-r--r--spec/cinder_common-opensuse_spec.rb16
-rw-r--r--spec/cinder_common-redhat_spec.rb16
-rw-r--r--spec/cinder_common_spec.rb210
-rw-r--r--spec/default_spec.rb4
-rw-r--r--spec/identity_registration_spec.rb96
-rw-r--r--spec/scheduler-opensuse_spec.rb40
-rw-r--r--spec/scheduler-redhat_spec.rb48
-rw-r--r--spec/scheduler_spec.rb82
-rw-r--r--spec/spec_helper.rb74
-rw-r--r--spec/volume-opensuse_spec.rb60
-rw-r--r--spec/volume-redhat_spec.rb64
-rw-r--r--spec/volume_spec.rb176
33 files changed, 726 insertions, 808 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 7a296ac..888678a 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,7 +1,15 @@
1# UTF-8 headers not generally in these files 1AllCops:
2Encoding: 2 Includes:
3 Enabled: false 3 - metadata.rb
4 - Gemfile
5 - attributes/**
6 - recipes/**
7 - spec/**
4 8
5# ignore long lines 9# ignore long lines
6LineLength: 10LineLength:
7 Enabled: false 11 Enabled: false
12
13# Allow small arrays before forcing %w or %W
14WordArray:
15 MinSize: 3
diff --git a/.tailor b/.tailor
deleted file mode 100644
index 99f0dcf..0000000
--- a/.tailor
+++ /dev/null
@@ -1,25 +0,0 @@
1Tailor.config do |config|
2 config.formatters "text"
3 config.file_set '**/*.rb' do |style|
4 style.max_line_length 80, level: :off
5 style.allow_camel_case_methods false, level: :error
6 style.allow_hard_tabs false, level: :error
7 style.allow_screaming_snake_case_classes false, level: :error
8 style.allow_trailing_line_spaces false, level: :error
9 style.allow_invalid_ruby false, level: :warn
10 style.indentation_spaces 2, level: :error
11 style.max_code_lines_in_class 300, level: :error
12 style.max_code_lines_in_method 30, level: :error
13 style.spaces_after_comma 1, level: :error
14 style.spaces_after_lbrace 1, level: :error
15 style.spaces_after_lbracket 0, level: :error
16 style.spaces_after_lparen 0, level: :error
17 style.spaces_before_comma 0, level: :error
18 style.spaces_before_lbrace 1, level: :error
19 style.spaces_before_rbrace 1, level: :error
20 style.spaces_before_rbracket 0, level: :error
21 style.spaces_before_rparen 0, level: :error
22 style.spaces_in_empty_braces 0, level: :error
23 style.trailing_newlines 1, level: :error
24 end
25end
diff --git a/Berksfile.lock b/Berksfile.lock
index d922561..bf5f86b 100644
--- a/Berksfile.lock
+++ b/Berksfile.lock
@@ -6,20 +6,20 @@
6 "openstack-image": { 6 "openstack-image": {
7 "locked_version": "8.0.0", 7 "locked_version": "8.0.0",
8 "git": "git://github.com/stackforge/cookbook-openstack-image.git", 8 "git": "git://github.com/stackforge/cookbook-openstack-image.git",
9 "ref": "900c9eef120e22368bb27062473ae549643e9594" 9 "ref": "2be8d1e01789f4e7a3fc7b6f8a2f43df3fae59c5"
10 }, 10 },
11 "openstack-identity": { 11 "openstack-identity": {
12 "locked_version": "8.0.0", 12 "locked_version": "8.0.0",
13 "git": "git://github.com/stackforge/cookbook-openstack-identity.git", 13 "git": "git://github.com/stackforge/cookbook-openstack-identity.git",
14 "ref": "3b001b7e07758e2c81b5ae4d1bff8e4a1472b24a" 14 "ref": "f4925084e583c29cb9007d9f2e1894761db264ef"
15 }, 15 },
16 "openstack-common": { 16 "openstack-common": {
17 "locked_version": "8.0.0", 17 "locked_version": "8.0.1",
18 "git": "git://github.com/stackforge/cookbook-openstack-common.git", 18 "git": "git://github.com/stackforge/cookbook-openstack-common.git",
19 "ref": "d5f852daf5d0f3001ddbf1688c43a4bb21e8ca00" 19 "ref": "5e7592dc180bc30348afe7b1ecb3328d0fbacc5e"
20 }, 20 },
21 "apt": { 21 "apt": {
22 "locked_version": "2.3.0" 22 "locked_version": "2.3.4"
23 }, 23 },
24 "selinux": { 24 "selinux": {
25 "locked_version": "0.6.2" 25 "locked_version": "0.6.2"
@@ -31,13 +31,13 @@
31 "locked_version": "1.4.2" 31 "locked_version": "1.4.2"
32 }, 32 },
33 "yum": { 33 "yum": {
34 "locked_version": "2.4.4" 34 "locked_version": "3.0.2"
35 }, 35 },
36 "database": { 36 "database": {
37 "locked_version": "1.4.0" 37 "locked_version": "1.6.0"
38 }, 38 },
39 "mysql": { 39 "mysql": {
40 "locked_version": "3.0.0" 40 "locked_version": "4.0.14"
41 }, 41 },
42 "openssl": { 42 "openssl": {
43 "locked_version": "1.1.0" 43 "locked_version": "1.1.0"
diff --git a/Gemfile b/Gemfile
index 76065e1..27706b4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,4 @@
1# encoding: UTF-8
1source 'https://rubygems.org' 2source 'https://rubygems.org'
2 3
3gem 'chef', '~> 11.8' 4gem 'chef', '~> 11.8'
diff --git a/Strainerfile b/Strainerfile
index bc1e0bb..9a2ec64 100644
--- a/Strainerfile
+++ b/Strainerfile
@@ -1,11 +1,5 @@
1# Strainerfile 1# Strainerfile
2rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile --config $SANDBOX/$COOKBOOK/.rubocop.yml 2rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
3rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml
4rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/attributes/ --config $SANDBOX/$COOKBOOK/attributes/.rubocop.yml
5rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/recipes/ --config $SANDBOX/$COOKBOOK/recipes/.rubocop.yml
6rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/spec/ --config $SANDBOX/$COOKBOOK/spec/.rubocop.yml
7# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
8# may want to add rubocop check for Berksfile and Gemfile
9knife test: bundle exec knife cookbook test $COOKBOOK 3knife test: bundle exec knife cookbook test $COOKBOOK
10foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK 4foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK
11chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec 5chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec
diff --git a/TESTING.md b/TESTING.md
index f4d5119..af426d1 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -14,15 +14,6 @@ To run the tests:
14 14
15[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits. 15[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.
16 16
17### Attribute Rules ###
18
19Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
20
21 [Gemfile and metadata.rb](.rubocop.yml)
22 [attributes/*.rb](attributes/.rubocop.yml)
23 [recipes/.rubocop.yml](recipes/.rubocop.yml)
24 [spec/.rubocop.yml](spec/.rubocop.yml)
25
26## Knife ## 17## Knife ##
27 18
28[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors. 19[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors.
diff --git a/attributes/.rubocop.yml b/attributes/.rubocop.yml
deleted file mode 100644
index c158f65..0000000
--- a/attributes/.rubocop.yml
+++ /dev/null
@@ -1,7 +0,0 @@
1# embedded attributes make for long lines
2LineLength:
3 Enabled: false
4
5# %w or %W have not generally been used in attribute files
6WordArray:
7 Enabled: false
diff --git a/attributes/default.rb b/attributes/default.rb
index 66c76f1..0aa593e 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -75,11 +75,11 @@ default['openstack']['block-storage']['quota_driver'] = 'cinder.quota.DbQuotaDri
75default['openstack']['block-storage']['rpc_thread_pool_size'] = 64 75default['openstack']['block-storage']['rpc_thread_pool_size'] = 64
76default['openstack']['block-storage']['rpc_conn_pool_size'] = 30 76default['openstack']['block-storage']['rpc_conn_pool_size'] = 30
77default['openstack']['block-storage']['rpc_response_timeout'] = 60 77default['openstack']['block-storage']['rpc_response_timeout'] = 60
78case node["openstack"]["mq"]["service_type"] 78case node['openstack']['mq']['service_type']
79when "rabbitmq" 79when 'rabbitmq'
80 default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_kombu" 80 default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_kombu'
81when "qpid" 81when 'qpid'
82 default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_qpid" 82 default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_qpid'
83end 83end
84 84
85# MQ options 85# MQ options
diff --git a/metadata.rb b/metadata.rb
index 68470b8..0c87b79 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -1,3 +1,4 @@
1# encoding: UTF-8
1name 'openstack-block-storage' 2name 'openstack-block-storage'
2maintainer 'AT&T Services, Inc.' 3maintainer 'AT&T Services, Inc.'
3maintainer_email 'cookbooks@lists.tfoundry.com' 4maintainer_email 'cookbooks@lists.tfoundry.com'
diff --git a/recipes/.rubocop-todo.yml b/recipes/.rubocop-todo.yml
deleted file mode 100644
index d5cfdab..0000000
--- a/recipes/.rubocop-todo.yml
+++ /dev/null
@@ -1,15 +0,0 @@
1# This configuration was generated by `rubocop --auto-gen-config`.
2# The point is for the user to remove these configuration records
3# one by one as the offences are removed from the code base.
4
5CollectionMethods:
6 Enabled: false
7
8Documentation:
9 Enabled: false
10
11HashSyntax:
12 Enabled: false
13
14StringLiterals:
15 Enabled: false
diff --git a/recipes/.rubocop.yml b/recipes/.rubocop.yml
deleted file mode 100644
index 446ebc4..0000000
--- a/recipes/.rubocop.yml
+++ /dev/null
@@ -1,3 +0,0 @@
1# embedded attributes make for long lines
2LineLength:
3 Enabled: false
diff --git a/recipes/api.rb b/recipes/api.rb
index a1267e6..66ceac4 100644
--- a/recipes/api.rb
+++ b/recipes/api.rb
@@ -25,14 +25,13 @@ class ::Chef::Recipe
25 include ::Openstack 25 include ::Openstack
26end 26end
27 27
28include_recipe "openstack-block-storage::cinder-common" 28include_recipe 'openstack-block-storage::cinder-common'
29 29
30platform_options = node["openstack"]["block-storage"]["platform"] 30platform_options = node['openstack']['block-storage']['platform']
31 31
32platform_options["cinder_api_packages"].each do |pkg| 32platform_options['cinder_api_packages'].each do |pkg|
33 package pkg do 33 package pkg do
34 options platform_options["package_overrides"] 34 options platform_options['package_overrides']
35
36 action :upgrade 35 action :upgrade
37 end 36 end
38end 37end
@@ -44,44 +43,43 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
44 end 43 end
45end 44end
46 45
47directory ::File.dirname(node["openstack"]["block-storage"]["api"]["auth"]["cache_dir"]) do 46directory ::File.dirname(node['openstack']['block-storage']['api']['auth']['cache_dir']) do
48 owner node["openstack"]["block-storage"]["user"] 47 owner node['openstack']['block-storage']['user']
49 group node["openstack"]["block-storage"]["group"] 48 group node['openstack']['block-storage']['group']
50 mode 00700 49 mode 00700
51end 50end
52 51
53service "cinder-api" do 52service 'cinder-api' do
54 service_name platform_options["cinder_api_service"] 53 service_name platform_options['cinder_api_service']
55 supports :status => true, :restart => true 54 supports status: true, restart: true
56
57 action :enable 55 action :enable
58 subscribes :restart, "template[/etc/cinder/cinder.conf]" 56 subscribes :restart, 'template[/etc/cinder/cinder.conf]'
59end 57end
60 58
61identity_endpoint = endpoint "identity-api" 59identity_endpoint = endpoint 'identity-api'
62identity_admin_endpoint = endpoint "identity-admin" 60identity_admin_endpoint = endpoint 'identity-admin'
63service_pass = get_password "service", "openstack-block-storage" 61service_pass = get_password 'service', 'openstack-block-storage'
64 62
65execute "cinder-manage db sync" 63execute 'cinder-manage db sync'
66 64
67template "/etc/cinder/api-paste.ini" do 65template '/etc/cinder/api-paste.ini' do
68 source "api-paste.ini.erb" 66 source 'api-paste.ini.erb'
69 group node["openstack"]["block-storage"]["group"] 67 group node['openstack']['block-storage']['group']
70 owner node["openstack"]["block-storage"]["user"] 68 owner node['openstack']['block-storage']['user']
71 mode 00644 69 mode 00644
72 variables( 70 variables(
73 :identity_endpoint => identity_endpoint, 71 identity_endpoint: identity_endpoint,
74 :identity_admin_endpoint => identity_admin_endpoint, 72 identity_admin_endpoint: identity_admin_endpoint,
75 :service_pass => service_pass 73 service_pass: service_pass
76 ) 74 )
77 75
78 notifies :restart, "service[cinder-api]", :immediately 76 notifies :restart, 'service[cinder-api]', :immediately
79end 77end
80 78
81template "/etc/cinder/policy.json" do 79template '/etc/cinder/policy.json' do
82 source "policy.json.erb" 80 source 'policy.json.erb'
83 owner node["openstack"]["block-storage"]["user"] 81 owner node['openstack']['block-storage']['user']
84 group node["openstack"]["block-storage"]["group"] 82 group node['openstack']['block-storage']['group']
85 mode 00644 83 mode 00644
86 notifies :restart, "service[cinder-api]" 84 notifies :restart, 'service[cinder-api]'
87end 85end
diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb
index b00e849..b5c2b5c 100644
--- a/recipes/cinder-common.rb
+++ b/recipes/cinder-common.rb
@@ -17,56 +17,55 @@ class ::Chef::Recipe
17 include ::Openstack 17 include ::Openstack
18end 18end
19 19
20if node["openstack"]["block-storage"]["syslog"]["use"] 20if node['openstack']['block-storage']['syslog']['use']
21 include_recipe "openstack-common::logging" 21 include_recipe 'openstack-common::logging'
22end 22end
23 23
24platform_options = node["openstack"]["block-storage"]["platform"] 24platform_options = node['openstack']['block-storage']['platform']
25 25
26platform_options["cinder_common_packages"].each do |pkg| 26platform_options['cinder_common_packages'].each do |pkg|
27 package pkg do 27 package pkg do
28 options platform_options["package_overrides"] 28 options platform_options['package_overrides']
29
30 action :upgrade 29 action :upgrade
31 end 30 end
32end 31end
33 32
34db_user = node["openstack"]["block-storage"]["db"]["username"] 33db_user = node['openstack']['block-storage']['db']['username']
35db_pass = get_password "db", "cinder" 34db_pass = get_password 'db', 'cinder'
36sql_connection = db_uri("volume", db_user, db_pass) 35sql_connection = db_uri('volume', db_user, db_pass)
37 36
38if node["openstack"]["block-storage"]["mq"]["service_type"] == "rabbitmq" 37if node['openstack']['block-storage']['mq']['service_type'] == 'rabbitmq'
39 if node["openstack"]["block-storage"]["rabbit"]["ha"] 38 if node['openstack']['block-storage']['rabbit']['ha']
40 rabbit_hosts = rabbit_servers 39 rabbit_hosts = rabbit_servers
41 end 40 end
42 rabbit_pass = get_password "user", node["openstack"]["block-storage"]["rabbit"]["username"] 41 rabbit_pass = get_password 'user', node['openstack']['block-storage']['rabbit']['username']
43end 42end
44 43
45glance_api_endpoint = endpoint "image-api" 44glance_api_endpoint = endpoint 'image-api'
46 45
47directory "/etc/cinder" do 46directory '/etc/cinder' do
48 group node["openstack"]["block-storage"]["group"] 47 group node['openstack']['block-storage']['group']
49 owner node["openstack"]["block-storage"]["user"] 48 owner node['openstack']['block-storage']['user']
50 mode 00750 49 mode 00750
51 action :create 50 action :create
52end 51end
53 52
54template "/etc/cinder/cinder.conf" do 53template '/etc/cinder/cinder.conf' do
55 source "cinder.conf.erb" 54 source 'cinder.conf.erb'
56 group node["openstack"]["block-storage"]["group"] 55 group node['openstack']['block-storage']['group']
57 owner node["openstack"]["block-storage"]["user"] 56 owner node['openstack']['block-storage']['user']
58 mode 00644 57 mode 00644
59 variables( 58 variables(
60 :sql_connection => sql_connection, 59 sql_connection: sql_connection,
61 :rabbit_password => rabbit_pass, 60 rabbit_password: rabbit_pass,
62 :rabbit_hosts => rabbit_hosts, 61 rabbit_hosts: rabbit_hosts,
63 :glance_host => glance_api_endpoint.host, 62 glance_host: glance_api_endpoint.host,
64 :glance_port => glance_api_endpoint.port 63 glance_port: glance_api_endpoint.port
65 ) 64 )
66end 65end
67 66
68directory node["openstack"]["block-storage"]["lock_path"] do 67directory node['openstack']['block-storage']['lock_path'] do
69 group node["openstack"]["block-storage"]["group"] 68 group node['openstack']['block-storage']['group']
70 owner node["openstack"]["block-storage"]["user"] 69 owner node['openstack']['block-storage']['user']
71 mode 00700 70 mode 00700
72end 71end
diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb
index 77ee126..fb87441 100644
--- a/recipes/identity_registration.rb
+++ b/recipes/identity_registration.rb
@@ -20,67 +20,63 @@
20# limitations under the License. 20# limitations under the License.
21# 21#
22 22
23require "uri" 23require 'uri'
24 24
25class ::Chef::Recipe 25class ::Chef::Recipe # rubocop:disable Documentation
26 include ::Openstack 26 include ::Openstack
27end 27end
28 28
29identity_admin_endpoint = endpoint "identity-admin" 29identity_admin_endpoint = endpoint 'identity-admin'
30bootstrap_token = secret "secrets", "openstack_identity_bootstrap_token" 30bootstrap_token = secret 'secrets', 'openstack_identity_bootstrap_token'
31auth_uri = ::URI.decode identity_admin_endpoint.to_s 31auth_uri = ::URI.decode identity_admin_endpoint.to_s
32cinder_api_endpoint = endpoint "volume-api" 32cinder_api_endpoint = endpoint 'volume-api'
33service_pass = get_password "service", "openstack-block-storage" 33service_pass = get_password 'service', 'openstack-block-storage'
34region = node["openstack"]["block-storage"]["region"] 34region = node['openstack']['block-storage']['region']
35service_tenant_name = node["openstack"]["block-storage"]["service_tenant_name"] 35service_tenant_name = node['openstack']['block-storage']['service_tenant_name']
36service_user = node["openstack"]["block-storage"]["service_user"] 36service_user = node['openstack']['block-storage']['service_user']
37service_role = node["openstack"]["block-storage"]["service_role"] 37service_role = node['openstack']['block-storage']['service_role']
38 38
39openstack_identity_register "Register Cinder Volume Service" do 39openstack_identity_register 'Register Cinder Volume Service' do
40 auth_uri auth_uri 40 auth_uri auth_uri
41 bootstrap_token bootstrap_token 41 bootstrap_token bootstrap_token
42 service_name "cinder" 42 service_name 'cinder'
43 service_type "volume" 43 service_type 'volume'
44 service_description "Cinder Volume Service" 44 service_description 'Cinder Volume Service'
45 endpoint_region region 45 endpoint_region region
46 endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s 46 endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s
47 endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s 47 endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s
48 endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s 48 endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s
49
50 action :create_service 49 action :create_service
51end 50end
52 51
53openstack_identity_register "Register Cinder Volume Endpoint" do 52openstack_identity_register 'Register Cinder Volume Endpoint' do
54 auth_uri auth_uri 53 auth_uri auth_uri
55 bootstrap_token bootstrap_token 54 bootstrap_token bootstrap_token
56 service_name "cinder" 55 service_name 'cinder'
57 service_type "volume" 56 service_type 'volume'
58 service_description "Cinder Volume Service" 57 service_description 'Cinder Volume Service'
59 endpoint_region region 58 endpoint_region region
60 endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s 59 endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s
61 endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s 60 endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s
62 endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s 61 endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s
63
64 action :create_endpoint 62 action :create_endpoint
65end 63end
66 64
67openstack_identity_register "Register Cinder Service User" do 65openstack_identity_register 'Register Cinder Service User' do
68 auth_uri auth_uri 66 auth_uri auth_uri
69 bootstrap_token bootstrap_token 67 bootstrap_token bootstrap_token
70 tenant_name service_tenant_name 68 tenant_name service_tenant_name
71 user_name service_user 69 user_name service_user
72 user_pass service_pass 70 user_pass service_pass
73 user_enabled true # Not required as this is the default 71 user_enabled true # Not required as this is the default
74
75 action :create_user 72 action :create_user
76end 73end
77 74
78openstack_identity_register "Grant service Role to Cinder Service User for Cinder Service Tenant" do 75openstack_identity_register 'Grant service Role to Cinder Service User for Cinder Service Tenant' do
79 auth_uri auth_uri 76 auth_uri auth_uri
80 bootstrap_token bootstrap_token 77 bootstrap_token bootstrap_token
81 tenant_name service_tenant_name 78 tenant_name service_tenant_name
82 user_name service_user 79 user_name service_user
83 role_name service_role 80 role_name service_role
84
85 action :grant_role 81 action :grant_role
86end 82end
diff --git a/recipes/scheduler.rb b/recipes/scheduler.rb
index 04dcd31..2cdebb5 100644
--- a/recipes/scheduler.rb
+++ b/recipes/scheduler.rb
@@ -21,13 +21,13 @@
21# limitations under the License. 21# limitations under the License.
22# 22#
23 23
24include_recipe "openstack-block-storage::cinder-common" 24include_recipe 'openstack-block-storage::cinder-common'
25 25
26platform_options = node["openstack"]["block-storage"]["platform"] 26platform_options = node['openstack']['block-storage']['platform']
27 27
28platform_options["cinder_scheduler_packages"].each do |pkg| 28platform_options['cinder_scheduler_packages'].each do |pkg|
29 package pkg do 29 package pkg do
30 options platform_options["package_overrides"] 30 options platform_options['package_overrides']
31 31
32 action :upgrade 32 action :upgrade
33 end 33 end
@@ -40,30 +40,30 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
40 end 40 end
41end 41end
42 42
43service "cinder-scheduler" do 43service 'cinder-scheduler' do
44 service_name platform_options["cinder_scheduler_service"] 44 service_name platform_options['cinder_scheduler_service']
45 supports :status => true, :restart => true 45 supports status: true, restart: true
46 action [:enable, :start] 46 action [:enable, :start]
47 subscribes :restart, "template[/etc/cinder/cinder.conf]" 47 subscribes :restart, 'template[/etc/cinder/cinder.conf]'
48end 48end
49 49
50audit_bin_dir = platform?("ubuntu") ? "/usr/bin" : "/usr/local/bin" 50audit_bin_dir = platform?('ubuntu') ? '/usr/bin' : '/usr/local/bin'
51audit_log = node["openstack"]["block-storage"]["cron"]["audit_logfile"] 51audit_log = node['openstack']['block-storage']['cron']['audit_logfile']
52 52
53if node["openstack"]["metering"] 53if node['openstack']['metering']
54 scheduler_role = node["openstack"]["block-storage"]["scheduler_role"] 54 scheduler_role = node['openstack']['block-storage']['scheduler_role']
55 results = search(:node, "roles:#{scheduler_role}") 55 results = search(:node, "roles:#{scheduler_role}")
56 cron_node = results.collect { |a| a.name }.sort[0] 56 cron_node = results.map { |a| a.name }.sort[0]
57 Chef::Log.debug("Volume audit cron node: #{cron_node}") 57 Chef::Log.debug("Volume audit cron node: #{cron_node}")
58 58
59 cron "cinder-volume-usage-audit" do 59 cron 'cinder-volume-usage-audit' do
60 day node["openstack"]["block-storage"]["cron"]["day"] || '*' 60 day node['openstack']['block-storage']['cron']['day'] || '*'
61 hour node["openstack"]["block-storage"]["cron"]["hour"] || '*' 61 hour node['openstack']['block-storage']['cron']['hour'] || '*'
62 minute node["openstack"]["block-storage"]["cron"]["minute"] 62 minute node['openstack']['block-storage']['cron']['minute']
63 month node["openstack"]["block-storage"]["cron"]["month"] || '*' 63 month node['openstack']['block-storage']['cron']['month'] || '*'
64 weekday node["openstack"]["block-storage"]["cron"]["weekday"] || '*' 64 weekday node['openstack']['block-storage']['cron']['weekday'] || '*'
65 command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1" 65 command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1"
66 action cron_node == node.name ? :create : :delete 66 action cron_node == node.name ? :create : :delete
67 user node["openstack"]["block-storage"]["user"] 67 user node['openstack']['block-storage']['user']
68 end 68 end
69end 69end
diff --git a/recipes/volume.rb b/recipes/volume.rb
index 13b30d9..538c2ee 100644
--- a/recipes/volume.rb
+++ b/recipes/volume.rb
@@ -26,13 +26,13 @@ class ::Chef::Recipe
26 include ::Openstack 26 include ::Openstack
27end 27end
28 28
29include_recipe "openstack-block-storage::cinder-common" 29include_recipe 'openstack-block-storage::cinder-common'
30 30
31platform_options = node["openstack"]["block-storage"]["platform"] 31platform_options = node['openstack']['block-storage']['platform']
32 32
33platform_options["cinder_volume_packages"].each do |pkg| 33platform_options['cinder_volume_packages'].each do |pkg|
34 package pkg do 34 package pkg do
35 options platform_options["package_overrides"] 35 options platform_options['package_overrides']
36 action :upgrade 36 action :upgrade
37 end 37 end
38end 38end
@@ -44,103 +44,103 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
44 end 44 end
45end 45end
46 46
47platform_options["cinder_iscsitarget_packages"].each do |pkg| 47platform_options['cinder_iscsitarget_packages'].each do |pkg|
48 package pkg do 48 package pkg do
49 options platform_options["package_overrides"] 49 options platform_options['package_overrides']
50 action :upgrade 50 action :upgrade
51 end 51 end
52end 52end
53 53
54case node["openstack"]["block-storage"]["volume"]["driver"] 54case node['openstack']['block-storage']['volume']['driver']
55when "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" 55when 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
56 node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = get_password "service", "netapp" 56 node.override['openstack']['block-storage']['netapp']['dfm_password'] = get_password 'service', 'netapp'
57 57
58when "cinder.volume.drivers.RBDDriver" 58when 'cinder.volume.drivers.RBDDriver'
59 node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = get_password "service", "rbd" 59 node.override['openstack']['block-storage']['rbd_secret_uuid'] = get_password 'service', 'rbd'
60 60
61when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" 61when 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
62 node.override["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = get_password "service", "netapp-filer" 62 node.override['openstack']['block-storage']['netapp']['netapp_server_password'] = get_password 'service', 'netapp-filer'
63 63
64 directory node["openstack"]["block-storage"]["nfs"]["mount_point_base"] do 64 directory node['openstack']['block-storage']['nfs']['mount_point_base'] do
65 owner node["openstack"]["block-storage"]["user"] 65 owner node['openstack']['block-storage']['user']
66 group node["openstack"]["block-storage"]["group"] 66 group node['openstack']['block-storage']['group']
67 action :create 67 action :create
68 end 68 end
69 69
70 template node["openstack"]["block-storage"]["nfs"]["shares_config"] do 70 template node['openstack']['block-storage']['nfs']['shares_config'] do
71 source "shares.conf.erb" 71 source 'shares.conf.erb'
72 mode "0600" 72 mode '0600'
73 owner node["openstack"]["block-storage"]["user"] 73 owner node['openstack']['block-storage']['user']
74 group node["openstack"]["block-storage"]["group"] 74 group node['openstack']['block-storage']['group']
75 variables( 75 variables(
76 "host" => node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"], 76 host: node['openstack']['block-storage']['netapp']['netapp_server_hostname'],
77 "export" => node["openstack"]["block-storage"]["netapp"]["export"] 77 export: node['openstack']['block-storage']['netapp']['export']
78 ) 78 )
79 notifies :restart, "service[cinder-volume]" 79 notifies :restart, 'service[cinder-volume]'
80 end 80 end
81 81
82 platform_options["cinder_nfs_packages"].each do |pkg| 82 platform_options['cinder_nfs_packages'].each do |pkg|
83 package pkg do 83 package pkg do
84 options platform_options["package_overrides"] 84 options platform_options['package_overrides']
85 action :upgrade 85 action :upgrade
86 end 86 end
87 end 87 end
88 88
89when "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" 89when 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
90 file node['openstack']['block-storage']['san']['san_private_key'] do 90 file node['openstack']['block-storage']['san']['san_private_key'] do
91 mode "0400" 91 mode '0400'
92 owner node["openstack"]["block-storage"]["user"] 92 owner node['openstack']['block-storage']['user']
93 group node["openstack"]["block-storage"]["group"] 93 group node['openstack']['block-storage']['group']
94end 94 end
95 95
96when "cinder.volume.drivers.lvm.LVMISCSIDriver" 96when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
97 if node["openstack"]["block-storage"]["volume"]["create_volume_group"] 97 if node['openstack']['block-storage']['volume']['create_volume_group']
98 volume_size = node["openstack"]["block-storage"]["volume"]["volume_group_size"] 98 volume_size = node['openstack']['block-storage']['volume']['volume_group_size']
99 seek_count = volume_size.to_i * 1024 99 seek_count = volume_size.to_i * 1024
100 # default volume group is 40G 100 # default volume group is 40G
101 seek_count = 40 * 1024 if seek_count == 0 101 seek_count = 40 * 1024 if seek_count == 0
102 vg_name = node["openstack"]["block-storage"]["volume"]["volume_group"] 102 vg_name = node['openstack']['block-storage']['volume']['volume_group']
103 vg_file = "#{node["openstack"]["block-storage"]["volume"]["state_path"]}/#{vg_name}.img" 103 vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
104 104
105 # create volume group 105 # create volume group
106 execute "Create Cinder volume group" do 106 execute 'Create Cinder volume group' do
107 command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})" 107 command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
108 action :run 108 action :run
109 not_if "vgs #{vg_name}" 109 not_if "vgs #{vg_name}"
110 end 110 end
111 111
112 template "/etc/init.d/cinder-group-active" do 112 template '/etc/init.d/cinder-group-active' do
113 source "cinder-group-active.erb" 113 source 'cinder-group-active.erb'
114 mode "755" 114 mode '755'
115 variables( 115 variables(
116 "volume_file" => vg_file 116 volume_file: vg_file
117 ) 117 )
118 notifies :start, "service[cinder-group-active]", :immediately 118 notifies :start, 'service[cinder-group-active]', :immediately
119 end 119 end
120 120
121 service "cinder-group-active" do 121 service 'cinder-group-active' do
122 service_name "cinder-group-active" 122 service_name 'cinder-group-active'
123 123
124 action [ :enable, :start ] 124 action [:enable, :start]
125 end 125 end
126 end 126 end
127end 127end
128 128
129service "cinder-volume" do 129service 'cinder-volume' do
130 service_name platform_options["cinder_volume_service"] 130 service_name platform_options['cinder_volume_service']
131 supports :status => true, :restart => true 131 supports status: true, restart: true
132 action [:enable, :start] 132 action [:enable, :start]
133 subscribes :restart, "template[/etc/cinder/cinder.conf]" 133 subscribes :restart, 'template[/etc/cinder/cinder.conf]'
134end 134end
135 135
136service "iscsitarget" do 136service 'iscsitarget' do
137 service_name platform_options["cinder_iscsitarget_service"] 137 service_name platform_options['cinder_iscsitarget_service']
138 supports :status => true, :restart => true 138 supports status: true, restart: true
139 action :enable 139 action :enable
140end 140end
141 141
142template "/etc/tgt/targets.conf" do 142template '/etc/tgt/targets.conf' do
143 source "targets.conf.erb" 143 source 'targets.conf.erb'
144 mode 00600 144 mode 00600
145 notifies :restart, "service[iscsitarget]", :immediately 145 notifies :restart, 'service[iscsitarget]', :immediately
146end 146end
diff --git a/spec/.rubocop-todo.yml b/spec/.rubocop-todo.yml
deleted file mode 100644
index f6ad301..0000000
--- a/spec/.rubocop-todo.yml
+++ /dev/null
@@ -1,17 +0,0 @@
1# This configuration was generated by `rubocop --auto-gen-config`.
2# The point is for the user to remove these configuration records
3# one by one as the offences are removed from the code base.
4
5HashSyntax:
6 Enabled: false
7
8MethodLength:
9 Enabled: false
10
11StringLiterals:
12 Enabled: false
13
14### in the .rubocop.yml
15# embedded attributes make for long lines
16LineLength:
17 Enabled: false
diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml
deleted file mode 100644
index 446ebc4..0000000
--- a/spec/.rubocop.yml
+++ /dev/null
@@ -1,3 +0,0 @@
1# embedded attributes make for long lines
2LineLength:
3 Enabled: false
diff --git a/spec/api-opensuse_spec.rb b/spec/api-opensuse_spec.rb
index daa81c3..c9678a7 100644
--- a/spec/api-opensuse_spec.rb
+++ b/spec/api-opensuse_spec.rb
@@ -2,41 +2,41 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::api" do 7describe 'openstack-block-storage::api' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "opensuse" do 9 describe 'opensuse' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
12 @chef_run.converge "openstack-block-storage::api" 12 @chef_run.converge 'openstack-block-storage::api'
13 end 13 end
14 14
15 it "installs cinder api packages" do 15 it 'installs cinder api packages' do
16 expect(@chef_run).to upgrade_package "openstack-cinder-api" 16 expect(@chef_run).to upgrade_package 'openstack-cinder-api'
17 end 17 end
18 18
19 it "installs mysql python packages by default" do 19 it 'installs mysql python packages by default' do
20 expect(@chef_run).to upgrade_package "python-mysql" 20 expect(@chef_run).to upgrade_package 'python-mysql'
21 end 21 end
22 22
23 it "installs postgresql python packages if explicitly told" do 23 it 'installs postgresql python packages if explicitly told' do
24 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 24 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
25 node = chef_run.node 25 node = chef_run.node
26 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 26 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
27 chef_run.converge "openstack-block-storage::api" 27 chef_run.converge 'openstack-block-storage::api'
28 28
29 expect(chef_run).to upgrade_package "python-psycopg2" 29 expect(chef_run).to upgrade_package 'python-psycopg2'
30 expect(chef_run).not_to upgrade_package "python-mysql" 30 expect(chef_run).not_to upgrade_package 'python-mysql'
31 end 31 end
32 32
33 it "starts cinder api on boot" do 33 it 'starts cinder api on boot' do
34 expect(@chef_run).to enable_service "openstack-cinder-api" 34 expect(@chef_run).to enable_service 'openstack-cinder-api'
35 end 35 end
36 36
37 expect_creates_policy_json( 37 expect_creates_policy_json(
38 "service[cinder-api]", "openstack-cinder", "openstack-cinder") 38 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
39 expect_creates_cinder_conf( 39 expect_creates_cinder_conf(
40 "service[cinder-api]", "openstack-cinder", "openstack-cinder") 40 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
41 end 41 end
42end 42end
diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb
index b9e771d..d1a444a 100644
--- a/spec/api-redhat_spec.rb
+++ b/spec/api-redhat_spec.rb
@@ -2,47 +2,47 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::api" do 7describe 'openstack-block-storage::api' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "redhat" do 9 describe 'redhat' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
12 @chef_run.converge "openstack-block-storage::api" 12 @chef_run.converge 'openstack-block-storage::api'
13 end 13 end
14 14
15 it "installs cinder api packages" do 15 it 'installs cinder api packages' do
16 expect(@chef_run).to upgrade_package "python-cinderclient" 16 expect(@chef_run).to upgrade_package 'python-cinderclient'
17 end 17 end
18 18
19 it "installs mysql python packages by default" do 19 it 'installs mysql python packages by default' do
20 expect(@chef_run).to upgrade_package "MySQL-python" 20 expect(@chef_run).to upgrade_package 'MySQL-python'
21 end 21 end
22 22
23 it "installs db2 python packages if explicitly told" do 23 it 'installs db2 python packages if explicitly told' do
24 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 24 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
25 node = chef_run.node 25 node = chef_run.node
26 node.set["openstack"]["db"]["volume"]["db_type"] = "db2" 26 node.set['openstack']['db']['volume']['db_type'] = 'db2'
27 chef_run.converge "openstack-block-storage::api" 27 chef_run.converge 'openstack-block-storage::api'
28 28
29 ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| 29 ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
30 expect(chef_run).to upgrade_package pkg 30 expect(chef_run).to upgrade_package pkg
31 end 31 end
32 end 32 end
33 33
34 it "installs postgresql python packages if explicitly told" do 34 it 'installs postgresql python packages if explicitly told' do
35 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 35 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
36 node = chef_run.node 36 node = chef_run.node
37 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 37 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
38 chef_run.converge "openstack-block-storage::api" 38 chef_run.converge 'openstack-block-storage::api'
39 39
40 expect(chef_run).to upgrade_package "python-psycopg2" 40 expect(chef_run).to upgrade_package 'python-psycopg2'
41 expect(chef_run).not_to upgrade_package "MySQL-python" 41 expect(chef_run).not_to upgrade_package 'MySQL-python'
42 end 42 end
43 43
44 it "starts cinder api on boot" do 44 it 'starts cinder api on boot' do
45 expect(@chef_run).to enable_service "openstack-cinder-api" 45 expect(@chef_run).to enable_service 'openstack-cinder-api'
46 end 46 end
47 end 47 end
48end 48end
diff --git a/spec/api_spec.rb b/spec/api_spec.rb
index 73b7ac2..2bf467e 100644
--- a/spec/api_spec.rb
+++ b/spec/api_spec.rb
@@ -2,152 +2,152 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::api" do 7describe 'openstack-block-storage::api' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "ubuntu" do 9 describe 'ubuntu' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
12 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 12 n.set['openstack']['block-storage']['syslog']['use'] = true
13 end 13 end
14 @chef_run.converge "openstack-block-storage::api" 14 @chef_run.converge 'openstack-block-storage::api'
15 end 15 end
16 16
17 expect_runs_openstack_common_logging_recipe 17 expect_runs_openstack_common_logging_recipe
18 18
19 it "doesn't run logging recipe" do 19 it 'does not run logging recipe' do
20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
21 chef_run.converge "openstack-block-storage::api" 21 chef_run.converge 'openstack-block-storage::api'
22 22
23 expect(chef_run).not_to include_recipe "openstack-common::logging" 23 expect(chef_run).not_to include_recipe 'openstack-common::logging'
24 end 24 end
25 25
26 it "installs cinder api packages" do 26 it 'installs cinder api packages' do
27 expect(@chef_run).to upgrade_package "cinder-api" 27 expect(@chef_run).to upgrade_package 'cinder-api'
28 expect(@chef_run).to upgrade_package "python-cinderclient" 28 expect(@chef_run).to upgrade_package 'python-cinderclient'
29 end 29 end
30 30
31 it "installs mysql python packages by default" do 31 it 'installs mysql python packages by default' do
32 expect(@chef_run).to upgrade_package "python-mysqldb" 32 expect(@chef_run).to upgrade_package 'python-mysqldb'
33 end 33 end
34 34
35 it "installs postgresql python packages if explicitly told" do 35 it 'installs postgresql python packages if explicitly told' do
36 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 36 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
37 node = chef_run.node 37 node = chef_run.node
38 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 38 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
39 chef_run.converge "openstack-block-storage::api" 39 chef_run.converge 'openstack-block-storage::api'
40 40
41 expect(chef_run).to upgrade_package "python-psycopg2" 41 expect(chef_run).to upgrade_package 'python-psycopg2'
42 expect(chef_run).not_to upgrade_package "python-mysqldb" 42 expect(chef_run).not_to upgrade_package 'python-mysqldb'
43 end 43 end
44 44
45 describe "/var/cache/cinder" do 45 describe '/var/cache/cinder' do
46 before do 46 before do
47 @dir = @chef_run.directory "/var/cache/cinder" 47 @dir = @chef_run.directory '/var/cache/cinder'
48 end 48 end
49 49
50 it "has proper owner" do 50 it 'has proper owner' do
51 expect(@dir.owner).to eq("cinder") 51 expect(@dir.owner).to eq('cinder')
52 expect(@dir.group).to eq("cinder") 52 expect(@dir.group).to eq('cinder')
53 end 53 end
54 54
55 it "has proper modes" do 55 it 'has proper modes' do
56 expect(sprintf("%o", @dir.mode)).to eq "700" 56 expect(sprintf('%o', @dir.mode)).to eq '700'
57 end 57 end
58 end 58 end
59 59
60 it "starts cinder api on boot" do 60 it 'starts cinder api on boot' do
61 expect(@chef_run).to enable_service "cinder-api" 61 expect(@chef_run).to enable_service 'cinder-api'
62 end 62 end
63 63
64 expect_creates_cinder_conf "service[cinder-api]", "cinder", "cinder" 64 expect_creates_cinder_conf 'service[cinder-api]', 'cinder', 'cinder'
65 65
66 describe "cinder.conf" do 66 describe 'cinder.conf' do
67 before do 67 before do
68 @file = "/etc/cinder/cinder.conf" 68 @file = '/etc/cinder/cinder.conf'
69 end 69 end
70 70
71 it "runs logging recipe if node attributes say to" do 71 it 'runs logging recipe if node attributes say to' do
72 expect(@chef_run).to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") 72 expect(@chef_run).to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
73 end 73 end
74 74
75 it "doesn't run logging recipe" do 75 it 'does not run logging recipe' do
76 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 76 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
77 chef_run.converge "openstack-block-storage::api" 77 chef_run.converge 'openstack-block-storage::api'
78 78
79 expect(chef_run).not_to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") 79 expect(chef_run).not_to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
80 end 80 end
81 81
82 it "has rbd driver settings" do 82 it 'has rbd driver settings' do
83 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 83 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
84 n.set["openstack"]["block-storage"]["volume"] = { 84 n.set['openstack']['block-storage']['volume'] = {
85 "driver" => "cinder.volume.drivers.RBDDriver" 85 'driver' => 'cinder.volume.drivers.RBDDriver'
86 } 86 }
87 end 87 end
88 chef_run.converge "openstack-block-storage::api" 88 chef_run.converge 'openstack-block-storage::api'
89 89
90 expect(chef_run).to render_file(@file).with_content(/^rbd_/) 90 expect(chef_run).to render_file(@file).with_content(/^rbd_/)
91 expect(chef_run).not_to render_file(@file).with_content(/^netapp_/) 91 expect(chef_run).not_to render_file(@file).with_content(/^netapp_/)
92 end 92 end
93 93
94 it "has netapp driver settings" do 94 it 'has netapp driver settings' do
95 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 95 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
96 n.set["openstack"]["block-storage"]["volume"] = { 96 n.set['openstack']['block-storage']['volume'] = {
97 "driver" => "cinder.volume.drivers.netapp.NetAppISCSIDriver" 97 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
98 } 98 }
99 end 99 end
100 chef_run.converge "openstack-block-storage::api" 100 chef_run.converge 'openstack-block-storage::api'
101 101
102 expect(chef_run).to render_file(@file).with_content(/^netapp_/) 102 expect(chef_run).to render_file(@file).with_content(/^netapp_/)
103 expect(chef_run).not_to render_file(@file).with_content(/^rbd_/) 103 expect(chef_run).not_to render_file(@file).with_content(/^rbd_/)
104 end 104 end
105 end 105 end
106 106
107 it "runs db migrations" do 107 it 'runs db migrations' do
108 cmd = "cinder-manage db sync" 108 cmd = 'cinder-manage db sync'
109 109
110 expect(@chef_run).to run_execute(cmd) 110 expect(@chef_run).to run_execute(cmd)
111 end 111 end
112 112
113 expect_creates_policy_json "service[cinder-api]", "cinder", "cinder" 113 expect_creates_policy_json 'service[cinder-api]', 'cinder', 'cinder'
114 114
115 describe "api-paste.ini" do 115 describe 'api-paste.ini' do
116 before do 116 before do
117 @file = @chef_run.template "/etc/cinder/api-paste.ini" 117 @file = @chef_run.template '/etc/cinder/api-paste.ini'
118 end 118 end
119 119
120 it "has proper owner" do 120 it 'has proper owner' do
121 expect(@file.owner).to eq("cinder") 121 expect(@file.owner).to eq('cinder')
122 expect(@file.group).to eq("cinder") 122 expect(@file.group).to eq('cinder')
123 end 123 end
124 124
125 it "has proper modes" do 125 it 'has proper modes' do
126 expect(sprintf("%o", @file.mode)).to eq "644" 126 expect(sprintf('%o', @file.mode)).to eq '644'
127 end 127 end
128 128
129 it "has signing_dir" do 129 it 'has signing_dir' do
130 expect(@chef_run).to render_file(@file.name).with_content("signing_dir = /var/cache/cinder/api") 130 expect(@chef_run).to render_file(@file.name).with_content('signing_dir = /var/cache/cinder/api')
131 end 131 end
132 132
133 it "notifies cinder-api restart" do 133 it 'notifies cinder-api restart' do
134 expect(@file).to notify("service[cinder-api]").to(:restart) 134 expect(@file).to notify('service[cinder-api]').to(:restart)
135 end 135 end
136 136
137 it "has auth_uri" do 137 it 'has auth_uri' do
138 expect(@chef_run).to render_file(@file.name).with_content("auth_uri = http://127.0.0.1:5000/v2.0") 138 expect(@chef_run).to render_file(@file.name).with_content('auth_uri = http://127.0.0.1:5000/v2.0')
139 end 139 end
140 140
141 it "has auth_host" do 141 it 'has auth_host' do
142 expect(@chef_run).to render_file(@file.name).with_content("auth_host = 127.0.0.1") 142 expect(@chef_run).to render_file(@file.name).with_content('auth_host = 127.0.0.1')
143 end 143 end
144 144
145 it "has auth_port" do 145 it 'has auth_port' do
146 expect(@chef_run).to render_file(@file.name).with_content("auth_port = 35357") 146 expect(@chef_run).to render_file(@file.name).with_content('auth_port = 35357')
147 end 147 end
148 148
149 it "has auth_protocol" do 149 it 'has auth_protocol' do
150 expect(@chef_run).to render_file(@file.name).with_content("auth_protocol = http") 150 expect(@chef_run).to render_file(@file.name).with_content('auth_protocol = http')
151 end 151 end
152 end 152 end
153 end 153 end
diff --git a/spec/cinder_common-opensuse_spec.rb b/spec/cinder_common-opensuse_spec.rb
index 9bf16c2..6576d3a 100644
--- a/spec/cinder_common-opensuse_spec.rb
+++ b/spec/cinder_common-opensuse_spec.rb
@@ -2,21 +2,21 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::cinder-common" do 7describe 'openstack-block-storage::cinder-common' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 before do 9 before do
10 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| 10 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
11 n.set["openstack"]["mq"] = { 11 n.set['openstack']['mq'] = {
12 "host" => "127.0.0.1" 12 'host' => '127.0.0.1'
13 } 13 }
14 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 14 n.set['openstack']['block-storage']['syslog']['use'] = true
15 end 15 end
16 @chef_run.converge "openstack-block-storage::cinder-common" 16 @chef_run.converge 'openstack-block-storage::cinder-common'
17 end 17 end
18 18
19 it "installs the openstack-cinder package" do 19 it 'installs the openstack-cinder package' do
20 expect(@chef_run).to upgrade_package "openstack-cinder" 20 expect(@chef_run).to upgrade_package 'openstack-cinder'
21 end 21 end
22end 22end
diff --git a/spec/cinder_common-redhat_spec.rb b/spec/cinder_common-redhat_spec.rb
index 313945a..829b0e4 100644
--- a/spec/cinder_common-redhat_spec.rb
+++ b/spec/cinder_common-redhat_spec.rb
@@ -2,21 +2,21 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::cinder-common" do 7describe 'openstack-block-storage::cinder-common' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 before do 9 before do
10 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| 10 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
11 n.set["openstack"]["mq"] = { 11 n.set['openstack']['mq'] = {
12 "host" => "127.0.0.1" 12 'host' => '127.0.0.1'
13 } 13 }
14 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 14 n.set['openstack']['block-storage']['syslog']['use'] = true
15 end 15 end
16 @chef_run.converge "openstack-block-storage::cinder-common" 16 @chef_run.converge 'openstack-block-storage::cinder-common'
17 end 17 end
18 18
19 it "installs the openstack-cinder package" do 19 it 'installs the openstack-cinder package' do
20 expect(@chef_run).to upgrade_package "openstack-cinder" 20 expect(@chef_run).to upgrade_package 'openstack-cinder'
21 end 21 end
22end 22end
diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb
index 396dde4..5032fd7 100644
--- a/spec/cinder_common_spec.rb
+++ b/spec/cinder_common_spec.rb
@@ -2,224 +2,224 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::cinder-common" do 7describe 'openstack-block-storage::cinder-common' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 before do 9 before do
10 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 10 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
11 n.set["openstack"]["mq"] = { 11 n.set['openstack']['mq'] = {
12 "host" => "127.0.0.1" 12 'host' => '127.0.0.1'
13 } 13 }
14 14
15 end 15 end
16 @chef_run.converge "openstack-block-storage::cinder-common" 16 @chef_run.converge 'openstack-block-storage::cinder-common'
17 end 17 end
18 18
19 it "installs the cinder-common package" do 19 it 'installs the cinder-common package' do
20 expect(@chef_run).to upgrade_package "cinder-common" 20 expect(@chef_run).to upgrade_package 'cinder-common'
21 end 21 end
22 22
23 describe "/etc/cinder" do 23 describe '/etc/cinder' do
24 before do 24 before do
25 @dir = @chef_run.directory "/etc/cinder" 25 @dir = @chef_run.directory '/etc/cinder'
26 end 26 end
27 27
28 it "has proper owner" do 28 it 'has proper owner' do
29 expect(@dir.owner).to eq("cinder") 29 expect(@dir.owner).to eq('cinder')
30 expect(@dir.group).to eq("cinder") 30 expect(@dir.group).to eq('cinder')
31 end 31 end
32 32
33 it "has proper modes" do 33 it 'has proper modes' do
34 expect(sprintf("%o", @dir.mode)).to eq "750" 34 expect(sprintf('%o', @dir.mode)).to eq '750'
35 end 35 end
36 end 36 end
37 37
38 describe "cinder.conf" do 38 describe 'cinder.conf' do
39 before do 39 before do
40 @file = @chef_run.template "/etc/cinder/cinder.conf" 40 @file = @chef_run.template '/etc/cinder/cinder.conf'
41 end 41 end
42 42
43 it "has proper owner" do 43 it 'has proper owner' do
44 expect(@file.owner).to eq("cinder") 44 expect(@file.owner).to eq('cinder')
45 expect(@file.group).to eq("cinder") 45 expect(@file.group).to eq('cinder')
46 end 46 end
47 47
48 it "has proper modes" do 48 it 'has proper modes' do
49 expect(sprintf("%o", @file.mode)).to eq "644" 49 expect(sprintf('%o', @file.mode)).to eq '644'
50 end 50 end
51 51
52 it "has name templates" do 52 it 'has name templates' do
53 expect(@chef_run).to render_file(@file.name).with_content("volume_name_template=volume-%s") 53 expect(@chef_run).to render_file(@file.name).with_content('volume_name_template=volume-%s')
54 expect(@chef_run).to render_file(@file.name).with_content("snapshot_name_template=snapshot-%s") 54 expect(@chef_run).to render_file(@file.name).with_content('snapshot_name_template=snapshot-%s')
55 end 55 end
56 56
57 it "has rpc_backend set" do 57 it 'has rpc_backend set' do
58 expect(@chef_run).to render_file(@file.name).with_content("rpc_backend=cinder.openstack.common.rpc.impl_kombu") 58 expect(@chef_run).to render_file(@file.name).with_content('rpc_backend=cinder.openstack.common.rpc.impl_kombu')
59 end 59 end
60 60
61 it "has has volumes_dir set" do 61 it 'has has volumes_dir set' do
62 expect(@chef_run).to render_file(@file.name).with_content("volumes_dir=/var/lib/cinder/volumes") 62 expect(@chef_run).to render_file(@file.name).with_content('volumes_dir=/var/lib/cinder/volumes')
63 end 63 end
64 64
65 it "has correct volume.driver set" do 65 it 'has correct volume.driver set' do
66 expect(@chef_run).to render_file(@file.name).with_content("volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver") 66 expect(@chef_run).to render_file(@file.name).with_content('volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver')
67 end 67 end
68 68
69 it "has rpc_thread_pool_size" do 69 it 'has rpc_thread_pool_size' do
70 expect(@chef_run).to render_file(@file.name).with_content("rpc_thread_pool_size=64") 70 expect(@chef_run).to render_file(@file.name).with_content('rpc_thread_pool_size=64')
71 end 71 end
72 72
73 it "has rpc_conn_pool_size" do 73 it 'has rpc_conn_pool_size' do
74 expect(@chef_run).to render_file(@file.name).with_content("rpc_conn_pool_size=30") 74 expect(@chef_run).to render_file(@file.name).with_content('rpc_conn_pool_size=30')
75 end 75 end
76 76
77 it "has rpc_response_timeout" do 77 it 'has rpc_response_timeout' do
78 expect(@chef_run).to render_file(@file.name).with_content("rpc_response_timeout=60") 78 expect(@chef_run).to render_file(@file.name).with_content('rpc_response_timeout=60')
79 end 79 end
80 80
81 it "has rabbit_host" do 81 it 'has rabbit_host' do
82 expect(@chef_run).to render_file(@file.name).with_content("rabbit_host=127.0.0.1") 82 expect(@chef_run).to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
83 end 83 end
84 84
85 it "does not have rabbit_hosts" do 85 it 'does not have rabbit_hosts' do
86 expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_hosts=") 86 expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_hosts=')
87 end 87 end
88 88
89 it "does not have rabbit_ha_queues" do 89 it 'does not have rabbit_ha_queues' do
90 expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_ha_queues=") 90 expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_ha_queues=')
91 end 91 end
92 92
93 it "has log_file" do 93 it 'has log_file' do
94 expect(@chef_run).to render_file(@file.name).with_content("log_file = /var/log/cinder/cinder.log") 94 expect(@chef_run).to render_file(@file.name).with_content('log_file = /var/log/cinder/cinder.log')
95 end 95 end
96 96
97 it "has log_config when syslog is true" do 97 it 'has log_config when syslog is true' do
98 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 98 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
99 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 99 n.set['openstack']['block-storage']['syslog']['use'] = true
100 end 100 end
101 chef_run.converge "openstack-block-storage::cinder-common" 101 chef_run.converge 'openstack-block-storage::cinder-common'
102 102
103 expect(chef_run).to render_file(@file.name).with_content("log_config = /etc/openstack/logging.conf") 103 expect(chef_run).to render_file(@file.name).with_content('log_config = /etc/openstack/logging.conf')
104 end 104 end
105 105
106 it "has rabbit_port" do 106 it 'has rabbit_port' do
107 expect(@chef_run).to render_file(@file.name).with_content("rabbit_port=5672") 107 expect(@chef_run).to render_file(@file.name).with_content('rabbit_port=5672')
108 end 108 end
109 109
110 it "has rabbit_userid" do 110 it 'has rabbit_userid' do
111 expect(@chef_run).to render_file(@file.name).with_content("rabbit_userid=guest") 111 expect(@chef_run).to render_file(@file.name).with_content('rabbit_userid=guest')
112 end 112 end
113 113
114 it "has rabbit_password" do 114 it 'has rabbit_password' do
115 expect(@chef_run).to render_file(@file.name).with_content("rabbit_password=rabbit-pass") 115 expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=rabbit-pass')
116 end 116 end
117 117
118 it "has rabbit_virtual_host" do 118 it 'has rabbit_virtual_host' do
119 expect(@chef_run).to render_file(@file.name).with_content("rabbit_virtual_host=/") 119 expect(@chef_run).to render_file(@file.name).with_content('rabbit_virtual_host=/')
120 end 120 end
121 121
122 describe "rabbit ha" do 122 describe 'rabbit ha' do
123 before do 123 before do
124 @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| 124 @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
125 n.set["openstack"]["block-storage"]["rabbit"]["ha"] = true 125 n.set['openstack']['block-storage']['rabbit']['ha'] = true
126 end 126 end
127 @chef_run.converge "openstack-block-storage::cinder-common" 127 @chef_run.converge 'openstack-block-storage::cinder-common'
128 end 128 end
129 129
130 it "has rabbit_hosts" do 130 it 'has rabbit_hosts' do
131 expect(@chef_run).to render_file(@file.name).with_content("rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672") 131 expect(@chef_run).to render_file(@file.name).with_content('rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672')
132 end 132 end
133 133
134 it "has rabbit_ha_queues" do 134 it 'has rabbit_ha_queues' do
135 expect(@chef_run).to render_file(@file.name).with_content("rabbit_ha_queues=True") 135 expect(@chef_run).to render_file(@file.name).with_content('rabbit_ha_queues=True')
136 end 136 end
137 137
138 it "does not have rabbit_host" do 138 it 'does not have rabbit_host' do
139 expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_host=127.0.0.1") 139 expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
140 end 140 end
141 141
142 it "does not have rabbit_port" do 142 it 'does not have rabbit_port' do
143 expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_port=5672") 143 expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_port=5672')
144 end 144 end
145 end 145 end
146 146
147 describe "qpid" do 147 describe 'qpid' do
148 before do 148 before do
149 @file = @chef_run.template "/etc/cinder/cinder.conf" 149 @file = @chef_run.template '/etc/cinder/cinder.conf'
150 @chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = "qpid" 150 @chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = 'qpid'
151 end 151 end
152 152
153 it "has qpid_hostname" do 153 it 'has qpid_hostname' do
154 expect(@chef_run).to render_file(@file.name).with_content("qpid_hostname=127.0.0.1") 154 expect(@chef_run).to render_file(@file.name).with_content('qpid_hostname=127.0.0.1')
155 end 155 end
156 156
157 it "has qpid_port" do 157 it 'has qpid_port' do
158 expect(@chef_run).to render_file(@file.name).with_content("qpid_port=5672") 158 expect(@chef_run).to render_file(@file.name).with_content('qpid_port=5672')
159 end 159 end
160 160
161 it "has qpid_username" do 161 it 'has qpid_username' do
162 expect(@chef_run).to render_file(@file.name).with_content("qpid_username=") 162 expect(@chef_run).to render_file(@file.name).with_content('qpid_username=')
163 end 163 end
164 164
165 it "has qpid_password" do 165 it 'has qpid_password' do
166 expect(@chef_run).to render_file(@file.name).with_content("qpid_password=") 166 expect(@chef_run).to render_file(@file.name).with_content('qpid_password=')
167 end 167 end
168 168
169 it "has qpid_sasl_mechanisms" do 169 it 'has qpid_sasl_mechanisms' do
170 expect(@chef_run).to render_file(@file.name).with_content("qpid_sasl_mechanisms=") 170 expect(@chef_run).to render_file(@file.name).with_content('qpid_sasl_mechanisms=')
171 end 171 end
172 172
173 it "has qpid_reconnect_timeout" do 173 it 'has qpid_reconnect_timeout' do
174 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_timeout=0") 174 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_timeout=0')
175 end 175 end
176 176
177 it "has qpid_reconnect_limit" do 177 it 'has qpid_reconnect_limit' do
178 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_limit=0") 178 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_limit=0')
179 end 179 end
180 180
181 it "has qpid_reconnect_interval_min" do 181 it 'has qpid_reconnect_interval_min' do
182 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_min=0") 182 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_min=0')
183 end 183 end
184 184
185 it "has qpid_reconnect_interval_max" do 185 it 'has qpid_reconnect_interval_max' do
186 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_max=0") 186 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_max=0')
187 end 187 end
188 188
189 it "has qpid_reconnect_interval" do 189 it 'has qpid_reconnect_interval' do
190 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval=0") 190 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval=0')
191 end 191 end
192 192
193 it "has qpid_reconnect" do 193 it 'has qpid_reconnect' do
194 expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect=true") 194 expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect=true')
195 end 195 end
196 196
197 it "has qpid_heartbeat" do 197 it 'has qpid_heartbeat' do
198 expect(@chef_run).to render_file(@file.name).with_content("qpid_heartbeat=60") 198 expect(@chef_run).to render_file(@file.name).with_content('qpid_heartbeat=60')
199 end 199 end
200 200
201 it "has qpid_protocol" do 201 it 'has qpid_protocol' do
202 expect(@chef_run).to render_file(@file.name).with_content("qpid_protocol=tcp") 202 expect(@chef_run).to render_file(@file.name).with_content('qpid_protocol=tcp')
203 end 203 end
204 204
205 it "has qpid_tcp_nodelay" do 205 it 'has qpid_tcp_nodelay' do
206 expect(@chef_run).to render_file(@file.name).with_content("qpid_tcp_nodelay=true") 206 expect(@chef_run).to render_file(@file.name).with_content('qpid_tcp_nodelay=true')
207 end 207 end
208 end 208 end
209 end 209 end
210 210
211 describe "/var/lock/cinder" do 211 describe '/var/lock/cinder' do
212 before do 212 before do
213 @dir = @chef_run.directory "/var/lock/cinder" 213 @dir = @chef_run.directory '/var/lock/cinder'
214 end 214 end
215 215
216 it "has proper owner" do 216 it 'has proper owner' do
217 expect(@dir.owner).to eq("cinder") 217 expect(@dir.owner).to eq('cinder')
218 expect(@dir.group).to eq("cinder") 218 expect(@dir.group).to eq('cinder')
219 end 219 end
220 220
221 it "has proper modes" do 221 it 'has proper modes' do
222 expect(sprintf("%o", @dir.mode)).to eq "700" 222 expect(sprintf('%o', @dir.mode)).to eq '700'
223 end 223 end
224 end 224 end
225 225
diff --git a/spec/default_spec.rb b/spec/default_spec.rb
index 85d361f..b97cfb7 100644
--- a/spec/default_spec.rb
+++ b/spec/default_spec.rb
@@ -2,7 +2,7 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::default" do 7describe 'openstack-block-storage::default' do
8end 8end
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 979dacc..48d9743 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -2,85 +2,85 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::identity_registration" do 7describe 'openstack-block-storage::identity_registration' do
8 before do 8 before do
9 block_storage_stubs 9 block_storage_stubs
10 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 10 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
11 @chef_run.converge "openstack-block-storage::identity_registration" 11 @chef_run.converge 'openstack-block-storage::identity_registration'
12 end 12 end
13 13
14 it "registers cinder volume service" do 14 it 'registers cinder volume service' do
15 resource = @chef_run.find_resource( 15 resource = @chef_run.find_resource(
16 "openstack-identity_register", 16 'openstack-identity_register',
17 "Register Cinder Volume Service" 17 'Register Cinder Volume Service'
18 ).to_hash 18 ).to_hash
19 19
20 expect(resource).to include( 20 expect(resource).to include(
21 :auth_uri => "http://127.0.0.1:35357/v2.0", 21 auth_uri: 'http://127.0.0.1:35357/v2.0',
22 :bootstrap_token => "bootstrap-token", 22 bootstrap_token: 'bootstrap-token',
23 :service_name => "cinder", 23 service_name: 'cinder',
24 :service_type => "volume", 24 service_type: 'volume',
25 :service_description => "Cinder Volume Service", 25 service_description: 'Cinder Volume Service',
26 :endpoint_region => "RegionOne", 26 endpoint_region: 'RegionOne',
27 :endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 27 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
28 :endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 28 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
29 :endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 29 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
30 :action => [:create_service] 30 action: [:create_service]
31 ) 31 )
32 end 32 end
33 33
34 it "registers cinder volume endpoint" do 34 it 'registers cinder volume endpoint' do
35 resource = @chef_run.find_resource( 35 resource = @chef_run.find_resource(
36 "openstack-identity_register", 36 'openstack-identity_register',
37 "Register Cinder Volume Endpoint" 37 'Register Cinder Volume Endpoint'
38 ).to_hash 38 ).to_hash
39 39
40 expect(resource).to include( 40 expect(resource).to include(
41 :auth_uri => "http://127.0.0.1:35357/v2.0", 41 auth_uri: 'http://127.0.0.1:35357/v2.0',
42 :bootstrap_token => "bootstrap-token", 42 bootstrap_token: 'bootstrap-token',
43 :service_name => "cinder", 43 service_name: 'cinder',
44 :service_type => "volume", 44 service_type: 'volume',
45 :service_description => "Cinder Volume Service", 45 service_description: 'Cinder Volume Service',
46 :endpoint_region => "RegionOne", 46 endpoint_region: 'RegionOne',
47 :endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 47 endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
48 :endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 48 endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
49 :endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", 49 endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
50 :action => [:create_endpoint] 50 action: [:create_endpoint]
51 ) 51 )
52 end 52 end
53 53
54 it "registers service user" do 54 it 'registers service user' do
55 resource = @chef_run.find_resource( 55 resource = @chef_run.find_resource(
56 "openstack-identity_register", 56 'openstack-identity_register',
57 "Register Cinder Service User" 57 'Register Cinder Service User'
58 ).to_hash 58 ).to_hash
59 59
60 expect(resource).to include( 60 expect(resource).to include(
61 :auth_uri => "http://127.0.0.1:35357/v2.0", 61 auth_uri: 'http://127.0.0.1:35357/v2.0',
62 :bootstrap_token => "bootstrap-token", 62 bootstrap_token: 'bootstrap-token',
63 :tenant_name => "service", 63 tenant_name: 'service',
64 :user_name => "cinder", 64 user_name: 'cinder',
65 :user_pass => "cinder-pass", 65 user_pass: 'cinder-pass',
66 :user_enabled => true, 66 user_enabled: true,
67 :action => [:create_user] 67 action: [:create_user]
68 ) 68 )
69 end 69 end
70 70
71 it "grants admin role to service user for service tenant" do 71 it 'grants admin role to service user for service tenant' do
72 resource = @chef_run.find_resource( 72 resource = @chef_run.find_resource(
73 "openstack-identity_register", 73 'openstack-identity_register',
74 "Grant service Role to Cinder Service User for Cinder Service Tenant" 74 'Grant service Role to Cinder Service User for Cinder Service Tenant'
75 ).to_hash 75 ).to_hash
76 76
77 expect(resource).to include( 77 expect(resource).to include(
78 :auth_uri => "http://127.0.0.1:35357/v2.0", 78 auth_uri: 'http://127.0.0.1:35357/v2.0',
79 :bootstrap_token => "bootstrap-token", 79 bootstrap_token: 'bootstrap-token',
80 :tenant_name => "service", 80 tenant_name: 'service',
81 :user_name => "cinder", 81 user_name: 'cinder',
82 :role_name => "admin", 82 role_name: 'admin',
83 :action => [:grant_role] 83 action: [:grant_role]
84 ) 84 )
85 end 85 end
86end 86end
diff --git a/spec/scheduler-opensuse_spec.rb b/spec/scheduler-opensuse_spec.rb
index 241002d..546de86 100644
--- a/spec/scheduler-opensuse_spec.rb
+++ b/spec/scheduler-opensuse_spec.rb
@@ -2,47 +2,47 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::scheduler" do 7describe 'openstack-block-storage::scheduler' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "opensuse" do 9 describe 'opensuse' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
12 @chef_run.converge "openstack-block-storage::scheduler" 12 @chef_run.converge 'openstack-block-storage::scheduler'
13 end 13 end
14 14
15 it "installs cinder scheduler packages" do 15 it 'installs cinder scheduler packages' do
16 expect(@chef_run).to upgrade_package "openstack-cinder-scheduler" 16 expect(@chef_run).to upgrade_package 'openstack-cinder-scheduler'
17 end 17 end
18 18
19 it "does not upgrade stevedore" do 19 it 'does not upgrade stevedore' do
20 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 20 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
21 chef_run.converge "openstack-block-storage::scheduler" 21 chef_run.converge 'openstack-block-storage::scheduler'
22 22
23 expect(chef_run).not_to upgrade_python_pip "stevedore" 23 expect(chef_run).not_to upgrade_python_pip 'stevedore'
24 end 24 end
25 25
26 it "installs mysql python packages by default" do 26 it 'installs mysql python packages by default' do
27 expect(@chef_run).to upgrade_package "python-mysql" 27 expect(@chef_run).to upgrade_package 'python-mysql'
28 end 28 end
29 29
30 it "installs postgresql python packages if explicitly told" do 30 it 'installs postgresql python packages if explicitly told' do
31 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 31 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
32 node = chef_run.node 32 node = chef_run.node
33 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 33 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
34 chef_run.converge "openstack-block-storage::scheduler" 34 chef_run.converge 'openstack-block-storage::scheduler'
35 35
36 expect(chef_run).to upgrade_package "python-psycopg2" 36 expect(chef_run).to upgrade_package 'python-psycopg2'
37 expect(chef_run).not_to upgrade_package "python-mysql" 37 expect(chef_run).not_to upgrade_package 'python-mysql'
38 end 38 end
39 39
40 it "starts cinder scheduler" do 40 it 'starts cinder scheduler' do
41 expect(@chef_run).to start_service "openstack-cinder-scheduler" 41 expect(@chef_run).to start_service 'openstack-cinder-scheduler'
42 end 42 end
43 43
44 it "starts cinder scheduler on boot" do 44 it 'starts cinder scheduler on boot' do
45 expect(@chef_run).to enable_service "openstack-cinder-scheduler" 45 expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
46 end 46 end
47 end 47 end
48end 48end
diff --git a/spec/scheduler-redhat_spec.rb b/spec/scheduler-redhat_spec.rb
index 76703d1..d49ec2b 100644
--- a/spec/scheduler-redhat_spec.rb
+++ b/spec/scheduler-redhat_spec.rb
@@ -2,58 +2,58 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::scheduler" do 7describe 'openstack-block-storage::scheduler' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "redhat" do 9 describe 'redhat' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
12 @chef_run.converge "openstack-block-storage::scheduler" 12 @chef_run.converge 'openstack-block-storage::scheduler'
13 end 13 end
14 14
15 it "installs cinder scheduler packages" do 15 it 'installs cinder scheduler packages' do
16 expect(@chef_run).to upgrade_package "openstack-cinder" 16 expect(@chef_run).to upgrade_package 'openstack-cinder'
17 end 17 end
18 18
19 it "does not upgrade stevedore" do 19 it 'does not upgrade stevedore' do
20 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 20 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
21 chef_run.converge "openstack-block-storage::scheduler" 21 chef_run.converge 'openstack-block-storage::scheduler'
22 22
23 expect(chef_run).not_to upgrade_python_pip "stevedore" 23 expect(chef_run).not_to upgrade_python_pip 'stevedore'
24 end 24 end
25 25
26 it "installs mysql python packages by default" do 26 it 'installs mysql python packages by default' do
27 expect(@chef_run).to upgrade_package "MySQL-python" 27 expect(@chef_run).to upgrade_package 'MySQL-python'
28 end 28 end
29 29
30 it "installs db2 python packages if explicitly told" do 30 it 'installs db2 python packages if explicitly told' do
31 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 31 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
32 node = chef_run.node 32 node = chef_run.node
33 node.set["openstack"]["db"]["volume"]["db_type"] = "db2" 33 node.set['openstack']['db']['volume']['db_type'] = 'db2'
34 chef_run.converge "openstack-block-storage::scheduler" 34 chef_run.converge 'openstack-block-storage::scheduler'
35 35
36 ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| 36 ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
37 expect(chef_run).to upgrade_package pkg 37 expect(chef_run).to upgrade_package pkg
38 end 38 end
39 end 39 end
40 40
41 it "installs postgresql python packages if explicitly told" do 41 it 'installs postgresql python packages if explicitly told' do
42 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 42 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
43 node = chef_run.node 43 node = chef_run.node
44 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 44 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
45 chef_run.converge "openstack-block-storage::scheduler" 45 chef_run.converge 'openstack-block-storage::scheduler'
46 46
47 expect(chef_run).to upgrade_package "python-psycopg2" 47 expect(chef_run).to upgrade_package 'python-psycopg2'
48 expect(chef_run).not_to upgrade_package "MySQL-python" 48 expect(chef_run).not_to upgrade_package 'MySQL-python'
49 end 49 end
50 50
51 it "starts cinder scheduler" do 51 it 'starts cinder scheduler' do
52 expect(@chef_run).to start_service "openstack-cinder-scheduler" 52 expect(@chef_run).to start_service 'openstack-cinder-scheduler'
53 end 53 end
54 54
55 it "starts cinder scheduler on boot" do 55 it 'starts cinder scheduler on boot' do
56 expect(@chef_run).to enable_service "openstack-cinder-scheduler" 56 expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
57 end 57 end
58 end 58 end
59end 59end
diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb
index 93fdba0..a5b40e5 100644
--- a/spec/scheduler_spec.rb
+++ b/spec/scheduler_spec.rb
@@ -2,71 +2,71 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::scheduler" do 7describe 'openstack-block-storage::scheduler' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "ubuntu" do 9 describe 'ubuntu' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
12 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 12 n.set['openstack']['block-storage']['syslog']['use'] = true
13 end 13 end
14 @chef_run.converge "openstack-block-storage::scheduler" 14 @chef_run.converge 'openstack-block-storage::scheduler'
15 end 15 end
16 16
17 expect_runs_openstack_common_logging_recipe 17 expect_runs_openstack_common_logging_recipe
18 18
19 it "doesn't run logging recipe" do 19 it 'does not run logging recipe' do
20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
21 chef_run.converge "openstack-block-storage::scheduler" 21 chef_run.converge 'openstack-block-storage::scheduler'
22 22
23 expect(chef_run).not_to include_recipe "openstack-common::logging" 23 expect(chef_run).not_to include_recipe 'openstack-common::logging'
24 end 24 end
25 25
26 it "installs cinder scheduler packages" do 26 it 'installs cinder scheduler packages' do
27 expect(@chef_run).to upgrade_package "cinder-scheduler" 27 expect(@chef_run).to upgrade_package 'cinder-scheduler'
28 end 28 end
29 29
30 it "installs mysql python packages by default" do 30 it 'installs mysql python packages by default' do
31 expect(@chef_run).to upgrade_package "python-mysqldb" 31 expect(@chef_run).to upgrade_package 'python-mysqldb'
32 end 32 end
33 33
34 it "installs postgresql python packages if explicitly told" do 34 it 'installs postgresql python packages if explicitly told' do
35 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 35 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
36 node = chef_run.node 36 node = chef_run.node
37 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 37 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
38 chef_run.converge "openstack-block-storage::scheduler" 38 chef_run.converge 'openstack-block-storage::scheduler'
39 39
40 expect(chef_run).to upgrade_package "python-psycopg2" 40 expect(chef_run).to upgrade_package 'python-psycopg2'
41 expect(chef_run).not_to upgrade_package "python-mysqldb" 41 expect(chef_run).not_to upgrade_package 'python-mysqldb'
42 end 42 end
43 43
44 it "starts cinder scheduler" do 44 it 'starts cinder scheduler' do
45 expect(@chef_run).to start_service "cinder-scheduler" 45 expect(@chef_run).to start_service 'cinder-scheduler'
46 end 46 end
47 47
48 it "starts cinder scheduler on boot" do 48 it 'starts cinder scheduler on boot' do
49 expect(@chef_run).to enable_service "cinder-scheduler" 49 expect(@chef_run).to enable_service 'cinder-scheduler'
50 end 50 end
51 51
52 it "doesn't run logging recipe" do 52 it 'does not run logging recipe' do
53 expect(@chef_run).to enable_service "cinder-scheduler" 53 expect(@chef_run).to enable_service 'cinder-scheduler'
54 end 54 end
55 55
56 it "doesn't setup cron when no metering" do 56 it 'does not setup cron when no metering' do
57 expect(@chef_run.cron("cinder-volume-usage-audit")).to be_nil 57 expect(@chef_run.cron('cinder-volume-usage-audit')).to be_nil
58 end 58 end
59 59
60 it "creates cron metering default" do 60 it 'creates cron metering default' do
61 ::Chef::Recipe.any_instance.stub(:search) 61 ::Chef::Recipe.any_instance.stub(:search)
62 .with(:node, "roles:os-block-storage-scheduler") 62 .with(:node, 'roles:os-block-storage-scheduler')
63 .and_return([OpenStruct.new(:name => "fauxhai.local")]) 63 .and_return([OpenStruct.new(name: 'fauxhai.local')])
64 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 64 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
65 n.set["openstack"]["metering"] = true 65 n.set['openstack']['metering'] = true
66 end 66 end
67 chef_run.converge "openstack-block-storage::scheduler" 67 chef_run.converge 'openstack-block-storage::scheduler'
68 cron = chef_run.cron "cinder-volume-usage-audit" 68 cron = chef_run.cron 'cinder-volume-usage-audit'
69 bin_str = "/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log" 69 bin_str = '/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log'
70 expect(cron.command).to match(/#{bin_str}/) 70 expect(cron.command).to match(/#{bin_str}/)
71 crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'], 71 crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'],
72 [:weekday, '*'], [:month, '*'], [:user, 'cinder']] 72 [:weekday, '*'], [:month, '*'], [:user, 'cinder']]
@@ -76,27 +76,27 @@ describe "openstack-block-storage::scheduler" do
76 expect(cron.action).to include :create 76 expect(cron.action).to include :create
77 end 77 end
78 78
79 it "creates cron metering custom" do 79 it 'creates cron metering custom' do
80 crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'], 80 crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'],
81 [:weekday, '5'], [:month, '11'], [:user, 'foobar']] 81 [:weekday, '5'], [:month, '11'], [:user, 'foobar']]
82 ::Chef::Recipe.any_instance.stub(:search) 82 ::Chef::Recipe.any_instance.stub(:search)
83 .with(:node, "roles:os-block-storage-scheduler") 83 .with(:node, 'roles:os-block-storage-scheduler')
84 .and_return([OpenStruct.new(:name => "foobar")]) 84 .and_return([OpenStruct.new(name: 'foobar')])
85 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 85 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
86 n.set["openstack"]["metering"] = true 86 n.set['openstack']['metering'] = true
87 crontests.each do |k, v| 87 crontests.each do |k, v|
88 n.set["openstack"]["block-storage"]["cron"][k.to_s] = v 88 n.set['openstack']['block-storage']['cron'][k.to_s] = v
89 end 89 end
90 n.set["openstack"]["block-storage"]["user"] = "foobar" 90 n.set['openstack']['block-storage']['user'] = 'foobar'
91 end 91 end
92 chef_run.converge "openstack-block-storage::scheduler" 92 chef_run.converge 'openstack-block-storage::scheduler'
93 cron = chef_run.cron "cinder-volume-usage-audit" 93 cron = chef_run.cron 'cinder-volume-usage-audit'
94 crontests.each do |k, v| 94 crontests.each do |k, v|
95 expect(cron.send(k)).to eq v 95 expect(cron.send(k)).to eq v
96 end 96 end
97 expect(cron.action).to include :delete 97 expect(cron.action).to include :delete
98 end 98 end
99 99
100 expect_creates_cinder_conf "service[cinder-scheduler]", "cinder", "cinder" 100 expect_creates_cinder_conf 'service[cinder-scheduler]', 'cinder', 'cinder'
101 end 101 end
102end 102end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index fa35f3d..7d6cb5a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -2,87 +2,87 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require "chefspec" 5require 'chefspec'
6require "chefspec/berkshelf" 6require 'chefspec/berkshelf'
7require "chef/application" 7require 'chef/application'
8require_relative "support/matcher" 8require_relative 'support/matcher'
9 9
10::LOG_LEVEL = :fatal 10::LOG_LEVEL = :fatal
11::OPENSUSE_OPTS = { 11::OPENSUSE_OPTS = {
12 :platform => "opensuse", 12 platform: 'opensuse',
13 :version => "12.3", 13 version: '12.3',
14 :log_level => ::LOG_LEVEL 14 log_level: ::LOG_LEVEL
15} 15}
16::REDHAT_OPTS = { 16::REDHAT_OPTS = {
17 :platform => "redhat", 17 platform: 'redhat',
18 :version => "6.3", 18 version: '6.3',
19 :log_level => ::LOG_LEVEL 19 log_level: ::LOG_LEVEL
20} 20}
21::UBUNTU_OPTS = { 21::UBUNTU_OPTS = {
22 :platform => "ubuntu", 22 platform: 'ubuntu',
23 :version => "12.04", 23 version: '12.04',
24 :log_level => ::LOG_LEVEL 24 log_level: ::LOG_LEVEL
25} 25}
26 26
27def block_storage_stubs 27def block_storage_stubs # rubocop:disable MethodLength
28 ::Chef::Recipe.any_instance.stub(:rabbit_servers) 28 ::Chef::Recipe.any_instance.stub(:rabbit_servers)
29 .and_return "1.1.1.1:5672,2.2.2.2:5672" 29 .and_return '1.1.1.1:5672,2.2.2.2:5672'
30 ::Chef::Recipe.any_instance.stub(:get_password).and_return '' 30 ::Chef::Recipe.any_instance.stub(:get_password).and_return ''
31 ::Chef::Recipe.any_instance.stub(:secret) 31 ::Chef::Recipe.any_instance.stub(:secret)
32 .with("secrets", "openstack_identity_bootstrap_token") 32 .with('secrets', 'openstack_identity_bootstrap_token')
33 .and_return "bootstrap-token" 33 .and_return 'bootstrap-token'
34 ::Chef::Recipe.any_instance.stub(:get_password) 34 ::Chef::Recipe.any_instance.stub(:get_password)
35 .with("user", "guest") 35 .with('user', 'guest')
36 .and_return "rabbit-pass" 36 .and_return 'rabbit-pass'
37 ::Chef::Recipe.any_instance.stub(:get_password) 37 ::Chef::Recipe.any_instance.stub(:get_password)
38 .with("service", "openstack-block-storage") 38 .with('service', 'openstack-block-storage')
39 .and_return "cinder-pass" 39 .and_return 'cinder-pass'
40 ::Chef::Application.stub(:fatal!) 40 ::Chef::Application.stub(:fatal!)
41end 41end
42 42
43def expect_runs_openstack_common_logging_recipe 43def expect_runs_openstack_common_logging_recipe
44 it "runs logging recipe if node attributes say to" do 44 it 'runs logging recipe if node attributes say to' do
45 expect(@chef_run).to include_recipe "openstack-common::logging" 45 expect(@chef_run).to include_recipe 'openstack-common::logging'
46 end 46 end
47end 47end
48 48
49def expect_creates_cinder_conf(service, user, group, action = :restart) 49def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength
50 describe "cinder.conf" do 50 describe 'cinder.conf' do
51 before do 51 before do
52 @file = @chef_run.template "/etc/cinder/cinder.conf" 52 @file = @chef_run.template '/etc/cinder/cinder.conf'
53 end 53 end
54 54
55 it "has proper owner" do 55 it 'has proper owner' do
56 expect(@file.owner).to eq(user) 56 expect(@file.owner).to eq(user)
57 expect(@file.group).to eq(group) 57 expect(@file.group).to eq(group)
58 end 58 end
59 59
60 it "has proper modes" do 60 it 'has proper modes' do
61 expect(sprintf("%o", @file.mode)).to eq "644" 61 expect(sprintf('%o', @file.mode)).to eq '644'
62 end 62 end
63 63
64 it "notifies service restart" do 64 it 'notifies service restart' do
65 expect(@file).to notify(service).to(action) 65 expect(@file).to notify(service).to(action)
66 end 66 end
67 end 67 end
68end 68end
69 69
70def expect_creates_policy_json(service, user, group, action = :restart) 70def expect_creates_policy_json(service, user, group, action = :restart) # rubocop:disable MethodLength
71 describe "policy.json" do 71 describe 'policy.json' do
72 before do 72 before do
73 @file = @chef_run.template "/etc/cinder/policy.json" 73 @file = @chef_run.template '/etc/cinder/policy.json'
74 end 74 end
75 75
76 it "has proper owner" do 76 it 'has proper owner' do
77 expect(@file.owner).to eq(user) 77 expect(@file.owner).to eq(user)
78 expect(@file.group).to eq(group) 78 expect(@file.group).to eq(group)
79 end 79 end
80 80
81 it "has proper modes" do 81 it 'has proper modes' do
82 expect(sprintf("%o", @file.mode)).to eq "644" 82 expect(sprintf('%o', @file.mode)).to eq '644'
83 end 83 end
84 84
85 it "notifies service restart" do 85 it 'notifies service restart' do
86 expect(@file).to notify(service).to(action) 86 expect(@file).to notify(service).to(action)
87 end 87 end
88 end 88 end
diff --git a/spec/volume-opensuse_spec.rb b/spec/volume-opensuse_spec.rb
index a08c9cc..f6dfb46 100644
--- a/spec/volume-opensuse_spec.rb
+++ b/spec/volume-opensuse_spec.rb
@@ -2,66 +2,66 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::volume" do 7describe 'openstack-block-storage::volume' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "opensuse" do 9 describe 'opensuse' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
12 @chef_run.converge "openstack-block-storage::volume" 12 @chef_run.converge 'openstack-block-storage::volume'
13 end 13 end
14 14
15 it "installs cinder volume packages" do 15 it 'installs cinder volume packages' do
16 expect(@chef_run).to upgrade_package "openstack-cinder-volume" 16 expect(@chef_run).to upgrade_package 'openstack-cinder-volume'
17 end 17 end
18 18
19 it "installs mysql python packages by default" do 19 it 'installs mysql python packages by default' do
20 expect(@chef_run).to upgrade_package "python-mysql" 20 expect(@chef_run).to upgrade_package 'python-mysql'
21 end 21 end
22 22
23 it "installs postgresql python packages if explicitly told" do 23 it 'installs postgresql python packages if explicitly told' do
24 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS 24 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
25 node = chef_run.node 25 node = chef_run.node
26 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 26 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
27 chef_run.converge "openstack-block-storage::volume" 27 chef_run.converge 'openstack-block-storage::volume'
28 28
29 expect(chef_run).to upgrade_package "python-psycopg2" 29 expect(chef_run).to upgrade_package 'python-psycopg2'
30 expect(chef_run).not_to upgrade_package "python-mysql" 30 expect(chef_run).not_to upgrade_package 'python-mysql'
31 end 31 end
32 32
33 it "installs cinder iscsi packages" do 33 it 'installs cinder iscsi packages' do
34 expect(@chef_run).to upgrade_package "tgt" 34 expect(@chef_run).to upgrade_package 'tgt'
35 end 35 end
36 36
37 it "starts cinder volume" do 37 it 'starts cinder volume' do
38 expect(@chef_run).to start_service "openstack-cinder-volume" 38 expect(@chef_run).to start_service 'openstack-cinder-volume'
39 end 39 end
40 40
41 it "starts cinder volume on boot" do 41 it 'starts cinder volume on boot' do
42 expected = "openstack-cinder-volume" 42 expected = 'openstack-cinder-volume'
43 expect(@chef_run).to enable_service expected 43 expect(@chef_run).to enable_service expected
44 end 44 end
45 45
46 it "starts iscsi target on boot" do 46 it 'starts iscsi target on boot' do
47 expect(@chef_run).to enable_service "tgtd" 47 expect(@chef_run).to enable_service 'tgtd'
48 end 48 end
49 49
50 it "installs nfs packages" do 50 it 'installs nfs packages' do
51 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| 51 chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
52 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" 52 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
53 end 53 end
54 chef_run.converge "openstack-block-storage::volume" 54 chef_run.converge 'openstack-block-storage::volume'
55 55
56 expect(chef_run).to upgrade_package "nfs-utils" 56 expect(chef_run).to upgrade_package 'nfs-utils'
57 expect(chef_run).not_to upgrade_package "nfs-utils-lib" 57 expect(chef_run).not_to upgrade_package 'nfs-utils-lib'
58 end 58 end
59 59
60 it "has opensuse include" do 60 it 'has opensuse include' do
61 file = "/etc/tgt/targets.conf" 61 file = '/etc/tgt/targets.conf'
62 62
63 expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") 63 expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
64 expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") 64 expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
65 end 65 end
66 end 66 end
67end 67end
diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb
index 726d92a..580dc73 100644
--- a/spec/volume-redhat_spec.rb
+++ b/spec/volume-redhat_spec.rb
@@ -2,73 +2,73 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::volume" do 7describe 'openstack-block-storage::volume' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "redhat" do 9 describe 'redhat' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 11 @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
12 @chef_run.converge "openstack-block-storage::volume" 12 @chef_run.converge 'openstack-block-storage::volume'
13 end 13 end
14 14
15 it "installs mysql python packages by default" do 15 it 'installs mysql python packages by default' do
16 expect(@chef_run).to upgrade_package "MySQL-python" 16 expect(@chef_run).to upgrade_package 'MySQL-python'
17 end 17 end
18 18
19 it "installs db2 python packages if explicitly told" do 19 it 'installs db2 python packages if explicitly told' do
20 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 20 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
21 node = chef_run.node 21 node = chef_run.node
22 node.set["openstack"]["db"]["volume"]["db_type"] = "db2" 22 node.set['openstack']['db']['volume']['db_type'] = 'db2'
23 chef_run.converge "openstack-block-storage::volume" 23 chef_run.converge 'openstack-block-storage::volume'
24 24
25 ["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| 25 ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
26 expect(chef_run).to upgrade_package pkg 26 expect(chef_run).to upgrade_package pkg
27 end 27 end
28 end 28 end
29 29
30 it "installs postgresql python packages if explicitly told" do 30 it 'installs postgresql python packages if explicitly told' do
31 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS 31 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
32 node = chef_run.node 32 node = chef_run.node
33 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 33 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
34 chef_run.converge "openstack-block-storage::volume" 34 chef_run.converge 'openstack-block-storage::volume'
35 35
36 expect(chef_run).to upgrade_package "python-psycopg2" 36 expect(chef_run).to upgrade_package 'python-psycopg2'
37 expect(chef_run).not_to upgrade_package "MySQL-python" 37 expect(chef_run).not_to upgrade_package 'MySQL-python'
38 end 38 end
39 39
40 it "installs cinder iscsi packages" do 40 it 'installs cinder iscsi packages' do
41 expect(@chef_run).to upgrade_package "scsi-target-utils" 41 expect(@chef_run).to upgrade_package 'scsi-target-utils'
42 end 42 end
43 43
44 it "starts cinder volume" do 44 it 'starts cinder volume' do
45 expect(@chef_run).to start_service "openstack-cinder-volume" 45 expect(@chef_run).to start_service 'openstack-cinder-volume'
46 end 46 end
47 47
48 it "starts cinder volume on boot" do 48 it 'starts cinder volume on boot' do
49 expected = "openstack-cinder-volume" 49 expected = 'openstack-cinder-volume'
50 expect(@chef_run).to enable_service expected 50 expect(@chef_run).to enable_service expected
51 end 51 end
52 52
53 it "starts iscsi target on boot" do 53 it 'starts iscsi target on boot' do
54 expect(@chef_run).to enable_service "tgtd" 54 expect(@chef_run).to enable_service 'tgtd'
55 end 55 end
56 56
57 it "installs nfs packages" do 57 it 'installs nfs packages' do
58 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| 58 chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
59 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" 59 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
60 end 60 end
61 chef_run.converge "openstack-block-storage::volume" 61 chef_run.converge 'openstack-block-storage::volume'
62 62
63 expect(chef_run).to upgrade_package "nfs-utils" 63 expect(chef_run).to upgrade_package 'nfs-utils'
64 expect(chef_run).to upgrade_package "nfs-utils-lib" 64 expect(chef_run).to upgrade_package 'nfs-utils-lib'
65 end 65 end
66 66
67 it "has redhat include" do 67 it 'has redhat include' do
68 file = "/etc/tgt/targets.conf" 68 file = '/etc/tgt/targets.conf'
69 69
70 expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") 70 expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
71 expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") 71 expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
72 end 72 end
73 end 73 end
74end 74end
diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb
index 0aaaf17..862bc7b 100644
--- a/spec/volume_spec.rb
+++ b/spec/volume_spec.rb
@@ -2,189 +2,189 @@
2# 2#
3# Cookbook Name:: openstack-block-storage 3# Cookbook Name:: openstack-block-storage
4 4
5require_relative "spec_helper" 5require_relative 'spec_helper'
6 6
7describe "openstack-block-storage::volume" do 7describe 'openstack-block-storage::volume' do
8 before { block_storage_stubs } 8 before { block_storage_stubs }
9 describe "ubuntu" do 9 describe 'ubuntu' do
10 before do 10 before do
11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 11 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
12 n.set["openstack"]["block-storage"]["syslog"]["use"] = true 12 n.set['openstack']['block-storage']['syslog']['use'] = true
13 end 13 end
14 @chef_run.converge "openstack-block-storage::volume" 14 @chef_run.converge 'openstack-block-storage::volume'
15 end 15 end
16 16
17 expect_runs_openstack_common_logging_recipe 17 expect_runs_openstack_common_logging_recipe
18 18
19 it "doesn't run logging recipe" do 19 it 'does not run logging recipe' do
20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 20 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
21 chef_run.converge "openstack-block-storage::volume" 21 chef_run.converge 'openstack-block-storage::volume'
22 22
23 expect(chef_run).not_to include_recipe "openstack-common::logging" 23 expect(chef_run).not_to include_recipe 'openstack-common::logging'
24 end 24 end
25 25
26 it "installs cinder volume packages" do 26 it 'installs cinder volume packages' do
27 expect(@chef_run).to upgrade_package "cinder-volume" 27 expect(@chef_run).to upgrade_package 'cinder-volume'
28 end 28 end
29 29
30 it "installs mysql python packages by default" do 30 it 'installs mysql python packages by default' do
31 expect(@chef_run).to upgrade_package "python-mysqldb" 31 expect(@chef_run).to upgrade_package 'python-mysqldb'
32 end 32 end
33 33
34 it "installs postgresql python packages if explicitly told" do 34 it 'installs postgresql python packages if explicitly told' do
35 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS 35 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
36 node = chef_run.node 36 node = chef_run.node
37 node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" 37 node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
38 chef_run.converge "openstack-block-storage::volume" 38 chef_run.converge 'openstack-block-storage::volume'
39 39
40 expect(chef_run).to upgrade_package "python-psycopg2" 40 expect(chef_run).to upgrade_package 'python-psycopg2'
41 expect(chef_run).not_to upgrade_package "python-mysqldb" 41 expect(chef_run).not_to upgrade_package 'python-mysqldb'
42 end 42 end
43 43
44 it "installs cinder iscsi packages" do 44 it 'installs cinder iscsi packages' do
45 expect(@chef_run).to upgrade_package "tgt" 45 expect(@chef_run).to upgrade_package 'tgt'
46 end 46 end
47 47
48 it "installs nfs packages" do 48 it 'installs nfs packages' do
49 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 49 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
50 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" 50 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
51 end 51 end
52 chef_run.converge "openstack-block-storage::volume" 52 chef_run.converge 'openstack-block-storage::volume'
53 53
54 expect(chef_run).to upgrade_package "nfs-common" 54 expect(chef_run).to upgrade_package 'nfs-common'
55 end 55 end
56 56
57 it "creates the nfs mount point" do 57 it 'creates the nfs mount point' do
58 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 58 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
59 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" 59 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
60 end 60 end
61 chef_run.converge "openstack-block-storage::volume" 61 chef_run.converge 'openstack-block-storage::volume'
62 62
63 expect(chef_run).to create_directory "/mnt/cinder-volumes" 63 expect(chef_run).to create_directory '/mnt/cinder-volumes'
64 end 64 end
65 65
66 it "configures netapp dfm password" do 66 it 'configures netapp dfm password' do
67 ::Chef::Recipe.any_instance.stub(:get_password).with("service", "netapp") 67 ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'netapp')
68 .and_return "netapp-pass" 68 .and_return 'netapp-pass'
69 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 69 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
70 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" 70 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
71 end 71 end
72 chef_run.converge "openstack-block-storage::volume" 72 chef_run.converge 'openstack-block-storage::volume'
73 n = chef_run.node["openstack"]["block-storage"]["netapp"]["dfm_password"] 73 n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
74 74
75 expect(n).to eq "netapp-pass" 75 expect(n).to eq 'netapp-pass'
76 end 76 end
77 77
78 it "configures rbd password" do 78 it 'configures rbd password' do
79 ::Chef::Recipe.any_instance.stub(:get_password).with("service", "rbd") 79 ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'rbd')
80 .and_return "rbd-pass" 80 .and_return 'rbd-pass'
81 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 81 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
82 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.RBDDriver" 82 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.RBDDriver'
83 end 83 end
84 chef_run.converge "openstack-block-storage::volume" 84 chef_run.converge 'openstack-block-storage::volume'
85 n = chef_run.node["openstack"]["block-storage"]["rbd_secret_uuid"] 85 n = chef_run.node['openstack']['block-storage']['rbd_secret_uuid']
86 86
87 expect(n).to eq "rbd-pass" 87 expect(n).to eq 'rbd-pass'
88 end 88 end
89 89
90 it "configures storewize private key" do 90 it 'configures storewize private key' do
91 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 91 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
92 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" 92 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
93 end 93 end
94 chef_run.converge "openstack-block-storage::volume" 94 chef_run.converge 'openstack-block-storage::volume'
95 95
96 san_key = chef_run.file chef_run.node["openstack"]["block-storage"]["san"]["san_private_key"] 96 san_key = chef_run.file chef_run.node['openstack']['block-storage']['san']['san_private_key']
97 expect(san_key.mode).to eq('0400') 97 expect(san_key.mode).to eq('0400')
98 end 98 end
99 99
100 it "configures storewize with iscsi" do 100 it 'configures storewize with iscsi' do
101 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 101 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
102 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" 102 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
103 n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "iSCSI" 103 n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
104 end 104 end
105 conf = "/etc/cinder/cinder.conf" 105 conf = '/etc/cinder/cinder.conf'
106 chef_run.converge "openstack-block-storage::volume" 106 chef_run.converge 'openstack-block-storage::volume'
107 107
108 # Test that the FC specific options are not set when connected via iSCSI 108 # Test that the FC specific options are not set when connected via iSCSI
109 expect(chef_run).not_to render_file(conf).with_content("storwize_svc_multipath_enabled") 109 expect(chef_run).not_to render_file(conf).with_content('storwize_svc_multipath_enabled')
110 end 110 end
111 111
112 it "configures storewize with fc" do 112 it 'configures storewize with fc' do
113 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 113 chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
114 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" 114 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
115 n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "FC" 115 n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
116 end 116 end
117 conf = "/etc/cinder/cinder.conf" 117 conf = '/etc/cinder/cinder.conf'
118 chef_run.converge "openstack-block-storage::volume" 118 chef_run.converge 'openstack-block-storage::volume'
119 119
120 # Test that the iSCSI specific options are not set when connected via FC 120 # Test that the iSCSI specific options are not set when connected via FC
121 expect(chef_run).not_to render_file(conf).with_content("storwize_svc_iscsi_chap_enabled") 121 expect(chef_run).not_to render_file(conf).with_content('storwize_svc_iscsi_chap_enabled')
122 end 122 end
123 123
124 it "starts cinder volume" do 124 it 'starts cinder volume' do
125 expect(@chef_run).to start_service "cinder-volume" 125 expect(@chef_run).to start_service 'cinder-volume'
126 end 126 end
127 127
128 it "starts cinder volume on boot" do 128 it 'starts cinder volume on boot' do
129 expect(@chef_run).to enable_service "cinder-volume" 129 expect(@chef_run).to enable_service 'cinder-volume'
130 end 130 end
131 131
132 expect_creates_cinder_conf "service[cinder-volume]", "cinder", "cinder" 132 expect_creates_cinder_conf 'service[cinder-volume]', 'cinder', 'cinder'
133 133
134 it "starts iscsi target on boot" do 134 it 'starts iscsi target on boot' do
135 expect(@chef_run).to enable_service "tgt" 135 expect(@chef_run).to enable_service 'tgt'
136 end 136 end
137 137
138 describe "targets.conf" do 138 describe 'targets.conf' do
139 before do 139 before do
140 @file = @chef_run.template "/etc/tgt/targets.conf" 140 @file = @chef_run.template '/etc/tgt/targets.conf'
141 end 141 end
142 142
143 it "has proper modes" do 143 it 'has proper modes' do
144 expect(sprintf("%o", @file.mode)).to eq "600" 144 expect(sprintf('%o', @file.mode)).to eq '600'
145 end 145 end
146 146
147 it "notifies iscsi restart" do 147 it 'notifies iscsi restart' do
148 expect(@file).to notify("service[iscsitarget]").to(:restart) 148 expect(@file).to notify('service[iscsitarget]').to(:restart)
149 end 149 end
150 150
151 it "has ubuntu include" do 151 it 'has ubuntu include' do
152 expect(@chef_run).to render_file(@file.name).with_content("include /etc/tgt/conf.d/*.conf") 152 expect(@chef_run).to render_file(@file.name).with_content('include /etc/tgt/conf.d/*.conf')
153 expect(@chef_run).not_to render_file(@file.name).with_content("include /var/lib/cinder/volumes/*") 153 expect(@chef_run).not_to render_file(@file.name).with_content('include /var/lib/cinder/volumes/*')
154 end 154 end
155 end 155 end
156 156
157 describe "create_vg" do 157 describe 'create_vg' do
158 before do 158 before do
159 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| 159 @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
160 n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.lvm.LVMISCSIDriver" 160 n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
161 n.set["openstack"]["block-storage"]["volume"]["create_volume_group"] = true 161 n.set['openstack']['block-storage']['volume']['create_volume_group'] = true
162 end 162 end
163 stub_command("vgs cinder-volumes").and_return(false) 163 stub_command('vgs cinder-volumes').and_return(false)
164 @filename = "/etc/init.d/cinder-group-active" 164 @filename = '/etc/init.d/cinder-group-active'
165 @chef_run.converge "openstack-block-storage::volume" 165 @chef_run.converge 'openstack-block-storage::volume'
166 @file = @chef_run.template(@filename) 166 @file = @chef_run.template(@filename)
167 end 167 end
168 168
169 it "cinder vg active" do 169 it 'cinder vg active' do
170 expect(@chef_run).to enable_service "cinder-group-active" 170 expect(@chef_run).to enable_service 'cinder-group-active'
171 end 171 end
172 172
173 it "create volume group" do 173 it 'create volume group' do
174 volume_size = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group_size"] 174 volume_size = @chef_run.node['openstack']['block-storage']['volume']['volume_group_size']
175 seek_count = volume_size.to_i * 1024 175 seek_count = volume_size.to_i * 1024
176 group_name = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group"] 176 group_name = @chef_run.node['openstack']['block-storage']['volume']['volume_group']
177 path = @chef_run.node["openstack"]["block-storage"]["volume"]["state_path"] 177 path = @chef_run.node['openstack']['block-storage']['volume']['state_path']
178 vg_file = "#{path}/#{group_name}.img" 178 vg_file = "#{path}/#{group_name}.img"
179 cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})" 179 cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})"
180 expect(@chef_run).to run_execute(cmd) 180 expect(@chef_run).to run_execute(cmd)
181 end 181 end
182 182
183 it "notifies cinder group active start" do 183 it 'notifies cinder group active start' do
184 expect(@file).to notify("service[cinder-group-active]").to(:start) 184 expect(@file).to notify('service[cinder-group-active]').to(:start)
185 end 185 end
186 186
187 it "creates cinder group active template file" do 187 it 'creates cinder group active template file' do
188 expect(@chef_run).to create_template(@filename) 188 expect(@chef_run).to create_template(@filename)
189 end 189 end
190 end 190 end