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
This commit is contained in:
Matt Ray 2014-01-15 23:12:39 -06:00
parent df36ef89be
commit 60e37c5eb0
33 changed files with 726 additions and 808 deletions

View File

@ -1,7 +1,15 @@
# UTF-8 headers not generally in these files AllCops:
Encoding: Includes:
Enabled: false - metadata.rb
- Gemfile
- attributes/**
- recipes/**
- spec/**
# ignore long lines # ignore long lines
LineLength: LineLength:
Enabled: false Enabled: false
# Allow small arrays before forcing %w or %W
WordArray:
MinSize: 3

25
.tailor
View File

@ -1,25 +0,0 @@
Tailor.config do |config|
config.formatters "text"
config.file_set '**/*.rb' do |style|
style.max_line_length 80, level: :off
style.allow_camel_case_methods false, level: :error
style.allow_hard_tabs false, level: :error
style.allow_screaming_snake_case_classes false, level: :error
style.allow_trailing_line_spaces false, level: :error
style.allow_invalid_ruby false, level: :warn
style.indentation_spaces 2, level: :error
style.max_code_lines_in_class 300, level: :error
style.max_code_lines_in_method 30, level: :error
style.spaces_after_comma 1, level: :error
style.spaces_after_lbrace 1, level: :error
style.spaces_after_lbracket 0, level: :error
style.spaces_after_lparen 0, level: :error
style.spaces_before_comma 0, level: :error
style.spaces_before_lbrace 1, level: :error
style.spaces_before_rbrace 1, level: :error
style.spaces_before_rbracket 0, level: :error
style.spaces_before_rparen 0, level: :error
style.spaces_in_empty_braces 0, level: :error
style.trailing_newlines 1, level: :error
end
end

View File

@ -6,20 +6,20 @@
"openstack-image": { "openstack-image": {
"locked_version": "8.0.0", "locked_version": "8.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-image.git", "git": "git://github.com/stackforge/cookbook-openstack-image.git",
"ref": "900c9eef120e22368bb27062473ae549643e9594" "ref": "2be8d1e01789f4e7a3fc7b6f8a2f43df3fae59c5"
}, },
"openstack-identity": { "openstack-identity": {
"locked_version": "8.0.0", "locked_version": "8.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-identity.git", "git": "git://github.com/stackforge/cookbook-openstack-identity.git",
"ref": "3b001b7e07758e2c81b5ae4d1bff8e4a1472b24a" "ref": "f4925084e583c29cb9007d9f2e1894761db264ef"
}, },
"openstack-common": { "openstack-common": {
"locked_version": "8.0.0", "locked_version": "8.0.1",
"git": "git://github.com/stackforge/cookbook-openstack-common.git", "git": "git://github.com/stackforge/cookbook-openstack-common.git",
"ref": "d5f852daf5d0f3001ddbf1688c43a4bb21e8ca00" "ref": "5e7592dc180bc30348afe7b1ecb3328d0fbacc5e"
}, },
"apt": { "apt": {
"locked_version": "2.3.0" "locked_version": "2.3.4"
}, },
"selinux": { "selinux": {
"locked_version": "0.6.2" "locked_version": "0.6.2"
@ -31,13 +31,13 @@
"locked_version": "1.4.2" "locked_version": "1.4.2"
}, },
"yum": { "yum": {
"locked_version": "2.4.4" "locked_version": "3.0.2"
}, },
"database": { "database": {
"locked_version": "1.4.0" "locked_version": "1.6.0"
}, },
"mysql": { "mysql": {
"locked_version": "3.0.0" "locked_version": "4.0.14"
}, },
"openssl": { "openssl": {
"locked_version": "1.1.0" "locked_version": "1.1.0"

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'chef', '~> 11.8' gem 'chef', '~> 11.8'

View File

@ -1,11 +1,5 @@
# Strainerfile # Strainerfile
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile --config $SANDBOX/$COOKBOOK/.rubocop.yml rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/attributes/ --config $SANDBOX/$COOKBOOK/attributes/.rubocop.yml
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/recipes/ --config $SANDBOX/$COOKBOOK/recipes/.rubocop.yml
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/spec/ --config $SANDBOX/$COOKBOOK/spec/.rubocop.yml
# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
# may want to add rubocop check for Berksfile and Gemfile
knife test: bundle exec knife cookbook test $COOKBOOK knife test: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK foodcritic: bundle exec foodcritic -f any -t ~FC003 $SANDBOX/$COOKBOOK
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec

View File

@ -14,15 +14,6 @@ To run the tests:
[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. [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.
### Attribute Rules ###
Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
[Gemfile and metadata.rb](.rubocop.yml)
[attributes/*.rb](attributes/.rubocop.yml)
[recipes/.rubocop.yml](recipes/.rubocop.yml)
[spec/.rubocop.yml](spec/.rubocop.yml)
## Knife ## ## Knife ##
[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. [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.

View File

@ -1,7 +0,0 @@
# embedded attributes make for long lines
LineLength:
Enabled: false
# %w or %W have not generally been used in attribute files
WordArray:
Enabled: false

View File

@ -75,11 +75,11 @@ default['openstack']['block-storage']['quota_driver'] = 'cinder.quota.DbQuotaDri
default['openstack']['block-storage']['rpc_thread_pool_size'] = 64 default['openstack']['block-storage']['rpc_thread_pool_size'] = 64
default['openstack']['block-storage']['rpc_conn_pool_size'] = 30 default['openstack']['block-storage']['rpc_conn_pool_size'] = 30
default['openstack']['block-storage']['rpc_response_timeout'] = 60 default['openstack']['block-storage']['rpc_response_timeout'] = 60
case node["openstack"]["mq"]["service_type"] case node['openstack']['mq']['service_type']
when "rabbitmq" when 'rabbitmq'
default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_kombu" default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_kombu'
when "qpid" when 'qpid'
default["openstack"]["block_storage"]["rpc_backend"] = "cinder.openstack.common.rpc.impl_qpid" default['openstack']['block_storage']['rpc_backend'] = 'cinder.openstack.common.rpc.impl_qpid'
end end
# MQ options # MQ options

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
name 'openstack-block-storage' name 'openstack-block-storage'
maintainer 'AT&T Services, Inc.' maintainer 'AT&T Services, Inc.'
maintainer_email 'cookbooks@lists.tfoundry.com' maintainer_email 'cookbooks@lists.tfoundry.com'

View File

@ -1,15 +0,0 @@
# This configuration was generated by `rubocop --auto-gen-config`.
# The point is for the user to remove these configuration records
# one by one as the offences are removed from the code base.
CollectionMethods:
Enabled: false
Documentation:
Enabled: false
HashSyntax:
Enabled: false
StringLiterals:
Enabled: false

View File

@ -1,3 +0,0 @@
# embedded attributes make for long lines
LineLength:
Enabled: false

View File

@ -25,14 +25,13 @@ class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
include_recipe "openstack-block-storage::cinder-common" include_recipe 'openstack-block-storage::cinder-common'
platform_options = node["openstack"]["block-storage"]["platform"] platform_options = node['openstack']['block-storage']['platform']
platform_options["cinder_api_packages"].each do |pkg| platform_options['cinder_api_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
@ -44,44 +43,43 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
end end
end end
directory ::File.dirname(node["openstack"]["block-storage"]["api"]["auth"]["cache_dir"]) do directory ::File.dirname(node['openstack']['block-storage']['api']['auth']['cache_dir']) do
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
mode 00700 mode 00700
end end
service "cinder-api" do service 'cinder-api' do
service_name platform_options["cinder_api_service"] service_name platform_options['cinder_api_service']
supports :status => true, :restart => true supports status: true, restart: true
action :enable action :enable
subscribes :restart, "template[/etc/cinder/cinder.conf]" subscribes :restart, 'template[/etc/cinder/cinder.conf]'
end end
identity_endpoint = endpoint "identity-api" identity_endpoint = endpoint 'identity-api'
identity_admin_endpoint = endpoint "identity-admin" identity_admin_endpoint = endpoint 'identity-admin'
service_pass = get_password "service", "openstack-block-storage" service_pass = get_password 'service', 'openstack-block-storage'
execute "cinder-manage db sync" execute 'cinder-manage db sync'
template "/etc/cinder/api-paste.ini" do template '/etc/cinder/api-paste.ini' do
source "api-paste.ini.erb" source 'api-paste.ini.erb'
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
mode 00644 mode 00644
variables( variables(
:identity_endpoint => identity_endpoint, identity_endpoint: identity_endpoint,
:identity_admin_endpoint => identity_admin_endpoint, identity_admin_endpoint: identity_admin_endpoint,
:service_pass => service_pass service_pass: service_pass
) )
notifies :restart, "service[cinder-api]", :immediately notifies :restart, 'service[cinder-api]', :immediately
end end
template "/etc/cinder/policy.json" do template '/etc/cinder/policy.json' do
source "policy.json.erb" source 'policy.json.erb'
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
mode 00644 mode 00644
notifies :restart, "service[cinder-api]" notifies :restart, 'service[cinder-api]'
end end

View File

@ -17,56 +17,55 @@ class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
if node["openstack"]["block-storage"]["syslog"]["use"] if node['openstack']['block-storage']['syslog']['use']
include_recipe "openstack-common::logging" include_recipe 'openstack-common::logging'
end end
platform_options = node["openstack"]["block-storage"]["platform"] platform_options = node['openstack']['block-storage']['platform']
platform_options["cinder_common_packages"].each do |pkg| platform_options['cinder_common_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
db_user = node["openstack"]["block-storage"]["db"]["username"] db_user = node['openstack']['block-storage']['db']['username']
db_pass = get_password "db", "cinder" db_pass = get_password 'db', 'cinder'
sql_connection = db_uri("volume", db_user, db_pass) sql_connection = db_uri('volume', db_user, db_pass)
if node["openstack"]["block-storage"]["mq"]["service_type"] == "rabbitmq" if node['openstack']['block-storage']['mq']['service_type'] == 'rabbitmq'
if node["openstack"]["block-storage"]["rabbit"]["ha"] if node['openstack']['block-storage']['rabbit']['ha']
rabbit_hosts = rabbit_servers rabbit_hosts = rabbit_servers
end end
rabbit_pass = get_password "user", node["openstack"]["block-storage"]["rabbit"]["username"] rabbit_pass = get_password 'user', node['openstack']['block-storage']['rabbit']['username']
end end
glance_api_endpoint = endpoint "image-api" glance_api_endpoint = endpoint 'image-api'
directory "/etc/cinder" do directory '/etc/cinder' do
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
mode 00750 mode 00750
action :create action :create
end end
template "/etc/cinder/cinder.conf" do template '/etc/cinder/cinder.conf' do
source "cinder.conf.erb" source 'cinder.conf.erb'
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
mode 00644 mode 00644
variables( variables(
:sql_connection => sql_connection, sql_connection: sql_connection,
:rabbit_password => rabbit_pass, rabbit_password: rabbit_pass,
:rabbit_hosts => rabbit_hosts, rabbit_hosts: rabbit_hosts,
:glance_host => glance_api_endpoint.host, glance_host: glance_api_endpoint.host,
:glance_port => glance_api_endpoint.port glance_port: glance_api_endpoint.port
) )
end end
directory node["openstack"]["block-storage"]["lock_path"] do directory node['openstack']['block-storage']['lock_path'] do
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
mode 00700 mode 00700
end end

View File

@ -20,67 +20,63 @@
# limitations under the License. # limitations under the License.
# #
require "uri" require 'uri'
class ::Chef::Recipe class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack include ::Openstack
end end
identity_admin_endpoint = endpoint "identity-admin" identity_admin_endpoint = endpoint 'identity-admin'
bootstrap_token = secret "secrets", "openstack_identity_bootstrap_token" bootstrap_token = secret 'secrets', 'openstack_identity_bootstrap_token'
auth_uri = ::URI.decode identity_admin_endpoint.to_s auth_uri = ::URI.decode identity_admin_endpoint.to_s
cinder_api_endpoint = endpoint "volume-api" cinder_api_endpoint = endpoint 'volume-api'
service_pass = get_password "service", "openstack-block-storage" service_pass = get_password 'service', 'openstack-block-storage'
region = node["openstack"]["block-storage"]["region"] region = node['openstack']['block-storage']['region']
service_tenant_name = node["openstack"]["block-storage"]["service_tenant_name"] service_tenant_name = node['openstack']['block-storage']['service_tenant_name']
service_user = node["openstack"]["block-storage"]["service_user"] service_user = node['openstack']['block-storage']['service_user']
service_role = node["openstack"]["block-storage"]["service_role"] service_role = node['openstack']['block-storage']['service_role']
openstack_identity_register "Register Cinder Volume Service" do openstack_identity_register 'Register Cinder Volume Service' do
auth_uri auth_uri auth_uri auth_uri
bootstrap_token bootstrap_token bootstrap_token bootstrap_token
service_name "cinder" service_name 'cinder'
service_type "volume" service_type 'volume'
service_description "Cinder Volume Service" service_description 'Cinder Volume Service'
endpoint_region region endpoint_region region
endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s
endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s
endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s
action :create_service action :create_service
end end
openstack_identity_register "Register Cinder Volume Endpoint" do openstack_identity_register 'Register Cinder Volume Endpoint' do
auth_uri auth_uri auth_uri auth_uri
bootstrap_token bootstrap_token bootstrap_token bootstrap_token
service_name "cinder" service_name 'cinder'
service_type "volume" service_type 'volume'
service_description "Cinder Volume Service" service_description 'Cinder Volume Service'
endpoint_region region endpoint_region region
endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s
endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s
endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s
action :create_endpoint action :create_endpoint
end end
openstack_identity_register "Register Cinder Service User" do openstack_identity_register 'Register Cinder Service User' do
auth_uri auth_uri auth_uri auth_uri
bootstrap_token bootstrap_token bootstrap_token bootstrap_token
tenant_name service_tenant_name tenant_name service_tenant_name
user_name service_user user_name service_user
user_pass service_pass user_pass service_pass
user_enabled true # Not required as this is the default user_enabled true # Not required as this is the default
action :create_user action :create_user
end end
openstack_identity_register "Grant service Role to Cinder Service User for Cinder Service Tenant" do openstack_identity_register 'Grant service Role to Cinder Service User for Cinder Service Tenant' do
auth_uri auth_uri auth_uri auth_uri
bootstrap_token bootstrap_token bootstrap_token bootstrap_token
tenant_name service_tenant_name tenant_name service_tenant_name
user_name service_user user_name service_user
role_name service_role role_name service_role
action :grant_role action :grant_role
end end

View File

@ -21,13 +21,13 @@
# limitations under the License. # limitations under the License.
# #
include_recipe "openstack-block-storage::cinder-common" include_recipe 'openstack-block-storage::cinder-common'
platform_options = node["openstack"]["block-storage"]["platform"] platform_options = node['openstack']['block-storage']['platform']
platform_options["cinder_scheduler_packages"].each do |pkg| platform_options['cinder_scheduler_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
@ -40,30 +40,30 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
end end
end end
service "cinder-scheduler" do service 'cinder-scheduler' do
service_name platform_options["cinder_scheduler_service"] service_name platform_options['cinder_scheduler_service']
supports :status => true, :restart => true supports status: true, restart: true
action [:enable, :start] action [:enable, :start]
subscribes :restart, "template[/etc/cinder/cinder.conf]" subscribes :restart, 'template[/etc/cinder/cinder.conf]'
end end
audit_bin_dir = platform?("ubuntu") ? "/usr/bin" : "/usr/local/bin" audit_bin_dir = platform?('ubuntu') ? '/usr/bin' : '/usr/local/bin'
audit_log = node["openstack"]["block-storage"]["cron"]["audit_logfile"] audit_log = node['openstack']['block-storage']['cron']['audit_logfile']
if node["openstack"]["metering"] if node['openstack']['metering']
scheduler_role = node["openstack"]["block-storage"]["scheduler_role"] scheduler_role = node['openstack']['block-storage']['scheduler_role']
results = search(:node, "roles:#{scheduler_role}") results = search(:node, "roles:#{scheduler_role}")
cron_node = results.collect { |a| a.name }.sort[0] cron_node = results.map { |a| a.name }.sort[0]
Chef::Log.debug("Volume audit cron node: #{cron_node}") Chef::Log.debug("Volume audit cron node: #{cron_node}")
cron "cinder-volume-usage-audit" do cron 'cinder-volume-usage-audit' do
day node["openstack"]["block-storage"]["cron"]["day"] || '*' day node['openstack']['block-storage']['cron']['day'] || '*'
hour node["openstack"]["block-storage"]["cron"]["hour"] || '*' hour node['openstack']['block-storage']['cron']['hour'] || '*'
minute node["openstack"]["block-storage"]["cron"]["minute"] minute node['openstack']['block-storage']['cron']['minute']
month node["openstack"]["block-storage"]["cron"]["month"] || '*' month node['openstack']['block-storage']['cron']['month'] || '*'
weekday node["openstack"]["block-storage"]["cron"]["weekday"] || '*' weekday node['openstack']['block-storage']['cron']['weekday'] || '*'
command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1" command "#{audit_bin_dir}/cinder-volume-usage-audit > #{audit_log} 2>&1"
action cron_node == node.name ? :create : :delete action cron_node == node.name ? :create : :delete
user node["openstack"]["block-storage"]["user"] user node['openstack']['block-storage']['user']
end end
end end

View File

@ -26,13 +26,13 @@ class ::Chef::Recipe
include ::Openstack include ::Openstack
end end
include_recipe "openstack-block-storage::cinder-common" include_recipe 'openstack-block-storage::cinder-common'
platform_options = node["openstack"]["block-storage"]["platform"] platform_options = node['openstack']['block-storage']['platform']
platform_options["cinder_volume_packages"].each do |pkg| platform_options['cinder_volume_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
@ -44,103 +44,103 @@ platform_options["#{db_type}_python_packages"].each do |pkg|
end end
end end
platform_options["cinder_iscsitarget_packages"].each do |pkg| platform_options['cinder_iscsitarget_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
case node["openstack"]["block-storage"]["volume"]["driver"] case node['openstack']['block-storage']['volume']['driver']
when "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" when 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
node.override["openstack"]["block-storage"]["netapp"]["dfm_password"] = get_password "service", "netapp" node.override['openstack']['block-storage']['netapp']['dfm_password'] = get_password 'service', 'netapp'
when "cinder.volume.drivers.RBDDriver" when 'cinder.volume.drivers.RBDDriver'
node.override["openstack"]["block-storage"]["rbd_secret_uuid"] = get_password "service", "rbd" node.override['openstack']['block-storage']['rbd_secret_uuid'] = get_password 'service', 'rbd'
when "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" when 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
node.override["openstack"]["block-storage"]["netapp"]["netapp_server_password"] = get_password "service", "netapp-filer" node.override['openstack']['block-storage']['netapp']['netapp_server_password'] = get_password 'service', 'netapp-filer'
directory node["openstack"]["block-storage"]["nfs"]["mount_point_base"] do directory node['openstack']['block-storage']['nfs']['mount_point_base'] do
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
action :create action :create
end end
template node["openstack"]["block-storage"]["nfs"]["shares_config"] do template node['openstack']['block-storage']['nfs']['shares_config'] do
source "shares.conf.erb" source 'shares.conf.erb'
mode "0600" mode '0600'
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
variables( variables(
"host" => node["openstack"]["block-storage"]["netapp"]["netapp_server_hostname"], host: node['openstack']['block-storage']['netapp']['netapp_server_hostname'],
"export" => node["openstack"]["block-storage"]["netapp"]["export"] export: node['openstack']['block-storage']['netapp']['export']
) )
notifies :restart, "service[cinder-volume]" notifies :restart, 'service[cinder-volume]'
end end
platform_options["cinder_nfs_packages"].each do |pkg| platform_options['cinder_nfs_packages'].each do |pkg|
package pkg do package pkg do
options platform_options["package_overrides"] options platform_options['package_overrides']
action :upgrade action :upgrade
end end
end end
when "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" when 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
file node['openstack']['block-storage']['san']['san_private_key'] do file node['openstack']['block-storage']['san']['san_private_key'] do
mode "0400" mode '0400'
owner node["openstack"]["block-storage"]["user"] owner node['openstack']['block-storage']['user']
group node["openstack"]["block-storage"]["group"] group node['openstack']['block-storage']['group']
end end
when "cinder.volume.drivers.lvm.LVMISCSIDriver" when 'cinder.volume.drivers.lvm.LVMISCSIDriver'
if node["openstack"]["block-storage"]["volume"]["create_volume_group"] if node['openstack']['block-storage']['volume']['create_volume_group']
volume_size = node["openstack"]["block-storage"]["volume"]["volume_group_size"] volume_size = node['openstack']['block-storage']['volume']['volume_group_size']
seek_count = volume_size.to_i * 1024 seek_count = volume_size.to_i * 1024
# default volume group is 40G # default volume group is 40G
seek_count = 40 * 1024 if seek_count == 0 seek_count = 40 * 1024 if seek_count == 0
vg_name = node["openstack"]["block-storage"]["volume"]["volume_group"] vg_name = node['openstack']['block-storage']['volume']['volume_group']
vg_file = "#{node["openstack"]["block-storage"]["volume"]["state_path"]}/#{vg_name}.img" vg_file = "#{node['openstack']['block-storage']['volume']['state_path']}/#{vg_name}.img"
# create volume group # create volume group
execute "Create Cinder volume group" do execute 'Create Cinder volume group' do
command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})" command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
action :run action :run
not_if "vgs #{vg_name}" not_if "vgs #{vg_name}"
end end
template "/etc/init.d/cinder-group-active" do template '/etc/init.d/cinder-group-active' do
source "cinder-group-active.erb" source 'cinder-group-active.erb'
mode "755" mode '755'
variables( variables(
"volume_file" => vg_file volume_file: vg_file
) )
notifies :start, "service[cinder-group-active]", :immediately notifies :start, 'service[cinder-group-active]', :immediately
end end
service "cinder-group-active" do service 'cinder-group-active' do
service_name "cinder-group-active" service_name 'cinder-group-active'
action [ :enable, :start ] action [:enable, :start]
end end
end end
end end
service "cinder-volume" do service 'cinder-volume' do
service_name platform_options["cinder_volume_service"] service_name platform_options['cinder_volume_service']
supports :status => true, :restart => true supports status: true, restart: true
action [:enable, :start] action [:enable, :start]
subscribes :restart, "template[/etc/cinder/cinder.conf]" subscribes :restart, 'template[/etc/cinder/cinder.conf]'
end end
service "iscsitarget" do service 'iscsitarget' do
service_name platform_options["cinder_iscsitarget_service"] service_name platform_options['cinder_iscsitarget_service']
supports :status => true, :restart => true supports status: true, restart: true
action :enable action :enable
end end
template "/etc/tgt/targets.conf" do template '/etc/tgt/targets.conf' do
source "targets.conf.erb" source 'targets.conf.erb'
mode 00600 mode 00600
notifies :restart, "service[iscsitarget]", :immediately notifies :restart, 'service[iscsitarget]', :immediately
end end

View File

@ -1,17 +0,0 @@
# This configuration was generated by `rubocop --auto-gen-config`.
# The point is for the user to remove these configuration records
# one by one as the offences are removed from the code base.
HashSyntax:
Enabled: false
MethodLength:
Enabled: false
StringLiterals:
Enabled: false
### in the .rubocop.yml
# embedded attributes make for long lines
LineLength:
Enabled: false

View File

@ -1,3 +0,0 @@
# embedded attributes make for long lines
LineLength:
Enabled: false

View File

@ -2,41 +2,41 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::api" do describe 'openstack-block-storage::api' do
before { block_storage_stubs } before { block_storage_stubs }
describe "opensuse" do describe 'opensuse' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-block-storage::api" @chef_run.converge 'openstack-block-storage::api'
end end
it "installs cinder api packages" do it 'installs cinder api packages' do
expect(@chef_run).to upgrade_package "openstack-cinder-api" expect(@chef_run).to upgrade_package 'openstack-cinder-api'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysql" expect(@chef_run).to upgrade_package 'python-mysql'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysql" expect(chef_run).not_to upgrade_package 'python-mysql'
end end
it "starts cinder api on boot" do it 'starts cinder api on boot' do
expect(@chef_run).to enable_service "openstack-cinder-api" expect(@chef_run).to enable_service 'openstack-cinder-api'
end end
expect_creates_policy_json( expect_creates_policy_json(
"service[cinder-api]", "openstack-cinder", "openstack-cinder") 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
expect_creates_cinder_conf( expect_creates_cinder_conf(
"service[cinder-api]", "openstack-cinder", "openstack-cinder") 'service[cinder-api]', 'openstack-cinder', 'openstack-cinder')
end end
end end

View File

@ -2,47 +2,47 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::api" do describe 'openstack-block-storage::api' do
before { block_storage_stubs } before { block_storage_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-block-storage::api" @chef_run.converge 'openstack-block-storage::api'
end end
it "installs cinder api packages" do it 'installs cinder api packages' do
expect(@chef_run).to upgrade_package "python-cinderclient" expect(@chef_run).to upgrade_package 'python-cinderclient'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "MySQL-python" expect(@chef_run).to upgrade_package 'MySQL-python'
end end
it "installs db2 python packages if explicitly told" do it 'installs db2 python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "db2" node.set['openstack']['db']['volume']['db_type'] = 'db2'
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(chef_run).to upgrade_package pkg expect(chef_run).to upgrade_package pkg
end end
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "MySQL-python" expect(chef_run).not_to upgrade_package 'MySQL-python'
end end
it "starts cinder api on boot" do it 'starts cinder api on boot' do
expect(@chef_run).to enable_service "openstack-cinder-api" expect(@chef_run).to enable_service 'openstack-cinder-api'
end end
end end
end end

View File

@ -2,152 +2,152 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::api" do describe 'openstack-block-storage::api' do
before { block_storage_stubs } before { block_storage_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
@chef_run.converge "openstack-block-storage::api" @chef_run.converge 'openstack-block-storage::api'
end end
expect_runs_openstack_common_logging_recipe expect_runs_openstack_common_logging_recipe
it "doesn't run logging recipe" do it 'does not run logging recipe' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).not_to include_recipe "openstack-common::logging" expect(chef_run).not_to include_recipe 'openstack-common::logging'
end end
it "installs cinder api packages" do it 'installs cinder api packages' do
expect(@chef_run).to upgrade_package "cinder-api" expect(@chef_run).to upgrade_package 'cinder-api'
expect(@chef_run).to upgrade_package "python-cinderclient" expect(@chef_run).to upgrade_package 'python-cinderclient'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysqldb" expect(@chef_run).to upgrade_package 'python-mysqldb'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysqldb" expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
describe "/var/cache/cinder" do describe '/var/cache/cinder' do
before do before do
@dir = @chef_run.directory "/var/cache/cinder" @dir = @chef_run.directory '/var/cache/cinder'
end end
it "has proper owner" do it 'has proper owner' do
expect(@dir.owner).to eq("cinder") expect(@dir.owner).to eq('cinder')
expect(@dir.group).to eq("cinder") expect(@dir.group).to eq('cinder')
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @dir.mode)).to eq "700" expect(sprintf('%o', @dir.mode)).to eq '700'
end end
end end
it "starts cinder api on boot" do it 'starts cinder api on boot' do
expect(@chef_run).to enable_service "cinder-api" expect(@chef_run).to enable_service 'cinder-api'
end end
expect_creates_cinder_conf "service[cinder-api]", "cinder", "cinder" expect_creates_cinder_conf 'service[cinder-api]', 'cinder', 'cinder'
describe "cinder.conf" do describe 'cinder.conf' do
before do before do
@file = "/etc/cinder/cinder.conf" @file = '/etc/cinder/cinder.conf'
end end
it "runs logging recipe if node attributes say to" do it 'runs logging recipe if node attributes say to' do
expect(@chef_run).to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") expect(@chef_run).to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
end end
it "doesn't run logging recipe" do it 'does not run logging recipe' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).not_to render_file(@file).with_content("log_config = /etc/openstack/logging.conf") expect(chef_run).not_to render_file(@file).with_content('log_config = /etc/openstack/logging.conf')
end end
it "has rbd driver settings" do it 'has rbd driver settings' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"] = { n.set['openstack']['block-storage']['volume'] = {
"driver" => "cinder.volume.drivers.RBDDriver" 'driver' => 'cinder.volume.drivers.RBDDriver'
} }
end end
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).to render_file(@file).with_content(/^rbd_/) expect(chef_run).to render_file(@file).with_content(/^rbd_/)
expect(chef_run).not_to render_file(@file).with_content(/^netapp_/) expect(chef_run).not_to render_file(@file).with_content(/^netapp_/)
end end
it "has netapp driver settings" do it 'has netapp driver settings' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"] = { n.set['openstack']['block-storage']['volume'] = {
"driver" => "cinder.volume.drivers.netapp.NetAppISCSIDriver" 'driver' => 'cinder.volume.drivers.netapp.NetAppISCSIDriver'
} }
end end
chef_run.converge "openstack-block-storage::api" chef_run.converge 'openstack-block-storage::api'
expect(chef_run).to render_file(@file).with_content(/^netapp_/) expect(chef_run).to render_file(@file).with_content(/^netapp_/)
expect(chef_run).not_to render_file(@file).with_content(/^rbd_/) expect(chef_run).not_to render_file(@file).with_content(/^rbd_/)
end end
end end
it "runs db migrations" do it 'runs db migrations' do
cmd = "cinder-manage db sync" cmd = 'cinder-manage db sync'
expect(@chef_run).to run_execute(cmd) expect(@chef_run).to run_execute(cmd)
end end
expect_creates_policy_json "service[cinder-api]", "cinder", "cinder" expect_creates_policy_json 'service[cinder-api]', 'cinder', 'cinder'
describe "api-paste.ini" do describe 'api-paste.ini' do
before do before do
@file = @chef_run.template "/etc/cinder/api-paste.ini" @file = @chef_run.template '/etc/cinder/api-paste.ini'
end end
it "has proper owner" do it 'has proper owner' do
expect(@file.owner).to eq("cinder") expect(@file.owner).to eq('cinder')
expect(@file.group).to eq("cinder") expect(@file.group).to eq('cinder')
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "644" expect(sprintf('%o', @file.mode)).to eq '644'
end end
it "has signing_dir" do it 'has signing_dir' do
expect(@chef_run).to render_file(@file.name).with_content("signing_dir = /var/cache/cinder/api") expect(@chef_run).to render_file(@file.name).with_content('signing_dir = /var/cache/cinder/api')
end end
it "notifies cinder-api restart" do it 'notifies cinder-api restart' do
expect(@file).to notify("service[cinder-api]").to(:restart) expect(@file).to notify('service[cinder-api]').to(:restart)
end end
it "has auth_uri" do it 'has auth_uri' do
expect(@chef_run).to render_file(@file.name).with_content("auth_uri = http://127.0.0.1:5000/v2.0") expect(@chef_run).to render_file(@file.name).with_content('auth_uri = http://127.0.0.1:5000/v2.0')
end end
it "has auth_host" do it 'has auth_host' do
expect(@chef_run).to render_file(@file.name).with_content("auth_host = 127.0.0.1") expect(@chef_run).to render_file(@file.name).with_content('auth_host = 127.0.0.1')
end end
it "has auth_port" do it 'has auth_port' do
expect(@chef_run).to render_file(@file.name).with_content("auth_port = 35357") expect(@chef_run).to render_file(@file.name).with_content('auth_port = 35357')
end end
it "has auth_protocol" do it 'has auth_protocol' do
expect(@chef_run).to render_file(@file.name).with_content("auth_protocol = http") expect(@chef_run).to render_file(@file.name).with_content('auth_protocol = http')
end end
end end
end end

View File

@ -2,21 +2,21 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::cinder-common" do describe 'openstack-block-storage::cinder-common' do
before { block_storage_stubs } before { block_storage_stubs }
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["openstack"]["mq"] = { n.set['openstack']['mq'] = {
"host" => "127.0.0.1" 'host' => '127.0.0.1'
} }
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
@chef_run.converge "openstack-block-storage::cinder-common" @chef_run.converge 'openstack-block-storage::cinder-common'
end end
it "installs the openstack-cinder package" do it 'installs the openstack-cinder package' do
expect(@chef_run).to upgrade_package "openstack-cinder" expect(@chef_run).to upgrade_package 'openstack-cinder'
end end
end end

View File

@ -2,21 +2,21 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::cinder-common" do describe 'openstack-block-storage::cinder-common' do
before { block_storage_stubs } before { block_storage_stubs }
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["mq"] = { n.set['openstack']['mq'] = {
"host" => "127.0.0.1" 'host' => '127.0.0.1'
} }
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
@chef_run.converge "openstack-block-storage::cinder-common" @chef_run.converge 'openstack-block-storage::cinder-common'
end end
it "installs the openstack-cinder package" do it 'installs the openstack-cinder package' do
expect(@chef_run).to upgrade_package "openstack-cinder" expect(@chef_run).to upgrade_package 'openstack-cinder'
end end
end end

View File

@ -2,224 +2,224 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::cinder-common" do describe 'openstack-block-storage::cinder-common' do
before { block_storage_stubs } before { block_storage_stubs }
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["mq"] = { n.set['openstack']['mq'] = {
"host" => "127.0.0.1" 'host' => '127.0.0.1'
} }
end end
@chef_run.converge "openstack-block-storage::cinder-common" @chef_run.converge 'openstack-block-storage::cinder-common'
end end
it "installs the cinder-common package" do it 'installs the cinder-common package' do
expect(@chef_run).to upgrade_package "cinder-common" expect(@chef_run).to upgrade_package 'cinder-common'
end end
describe "/etc/cinder" do describe '/etc/cinder' do
before do before do
@dir = @chef_run.directory "/etc/cinder" @dir = @chef_run.directory '/etc/cinder'
end end
it "has proper owner" do it 'has proper owner' do
expect(@dir.owner).to eq("cinder") expect(@dir.owner).to eq('cinder')
expect(@dir.group).to eq("cinder") expect(@dir.group).to eq('cinder')
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @dir.mode)).to eq "750" expect(sprintf('%o', @dir.mode)).to eq '750'
end end
end end
describe "cinder.conf" do describe 'cinder.conf' do
before do before do
@file = @chef_run.template "/etc/cinder/cinder.conf" @file = @chef_run.template '/etc/cinder/cinder.conf'
end end
it "has proper owner" do it 'has proper owner' do
expect(@file.owner).to eq("cinder") expect(@file.owner).to eq('cinder')
expect(@file.group).to eq("cinder") expect(@file.group).to eq('cinder')
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "644" expect(sprintf('%o', @file.mode)).to eq '644'
end end
it "has name templates" do it 'has name templates' do
expect(@chef_run).to render_file(@file.name).with_content("volume_name_template=volume-%s") expect(@chef_run).to render_file(@file.name).with_content('volume_name_template=volume-%s')
expect(@chef_run).to render_file(@file.name).with_content("snapshot_name_template=snapshot-%s") expect(@chef_run).to render_file(@file.name).with_content('snapshot_name_template=snapshot-%s')
end end
it "has rpc_backend set" do it 'has rpc_backend set' do
expect(@chef_run).to render_file(@file.name).with_content("rpc_backend=cinder.openstack.common.rpc.impl_kombu") expect(@chef_run).to render_file(@file.name).with_content('rpc_backend=cinder.openstack.common.rpc.impl_kombu')
end end
it "has has volumes_dir set" do it 'has has volumes_dir set' do
expect(@chef_run).to render_file(@file.name).with_content("volumes_dir=/var/lib/cinder/volumes") expect(@chef_run).to render_file(@file.name).with_content('volumes_dir=/var/lib/cinder/volumes')
end end
it "has correct volume.driver set" do it 'has correct volume.driver set' do
expect(@chef_run).to render_file(@file.name).with_content("volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver") expect(@chef_run).to render_file(@file.name).with_content('volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver')
end end
it "has rpc_thread_pool_size" do it 'has rpc_thread_pool_size' do
expect(@chef_run).to render_file(@file.name).with_content("rpc_thread_pool_size=64") expect(@chef_run).to render_file(@file.name).with_content('rpc_thread_pool_size=64')
end end
it "has rpc_conn_pool_size" do it 'has rpc_conn_pool_size' do
expect(@chef_run).to render_file(@file.name).with_content("rpc_conn_pool_size=30") expect(@chef_run).to render_file(@file.name).with_content('rpc_conn_pool_size=30')
end end
it "has rpc_response_timeout" do it 'has rpc_response_timeout' do
expect(@chef_run).to render_file(@file.name).with_content("rpc_response_timeout=60") expect(@chef_run).to render_file(@file.name).with_content('rpc_response_timeout=60')
end end
it "has rabbit_host" do it 'has rabbit_host' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_host=127.0.0.1") expect(@chef_run).to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
end end
it "does not have rabbit_hosts" do it 'does not have rabbit_hosts' do
expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_hosts=") expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_hosts=')
end end
it "does not have rabbit_ha_queues" do it 'does not have rabbit_ha_queues' do
expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_ha_queues=") expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_ha_queues=')
end end
it "has log_file" do it 'has log_file' do
expect(@chef_run).to render_file(@file.name).with_content("log_file = /var/log/cinder/cinder.log") expect(@chef_run).to render_file(@file.name).with_content('log_file = /var/log/cinder/cinder.log')
end end
it "has log_config when syslog is true" do it 'has log_config when syslog is true' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
chef_run.converge "openstack-block-storage::cinder-common" chef_run.converge 'openstack-block-storage::cinder-common'
expect(chef_run).to render_file(@file.name).with_content("log_config = /etc/openstack/logging.conf") expect(chef_run).to render_file(@file.name).with_content('log_config = /etc/openstack/logging.conf')
end end
it "has rabbit_port" do it 'has rabbit_port' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_port=5672") expect(@chef_run).to render_file(@file.name).with_content('rabbit_port=5672')
end end
it "has rabbit_userid" do it 'has rabbit_userid' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_userid=guest") expect(@chef_run).to render_file(@file.name).with_content('rabbit_userid=guest')
end end
it "has rabbit_password" do it 'has rabbit_password' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_password=rabbit-pass") expect(@chef_run).to render_file(@file.name).with_content('rabbit_password=rabbit-pass')
end end
it "has rabbit_virtual_host" do it 'has rabbit_virtual_host' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_virtual_host=/") expect(@chef_run).to render_file(@file.name).with_content('rabbit_virtual_host=/')
end end
describe "rabbit ha" do describe 'rabbit ha' do
before do before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["block-storage"]["rabbit"]["ha"] = true n.set['openstack']['block-storage']['rabbit']['ha'] = true
end end
@chef_run.converge "openstack-block-storage::cinder-common" @chef_run.converge 'openstack-block-storage::cinder-common'
end end
it "has rabbit_hosts" do it 'has rabbit_hosts' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672") expect(@chef_run).to render_file(@file.name).with_content('rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672')
end end
it "has rabbit_ha_queues" do it 'has rabbit_ha_queues' do
expect(@chef_run).to render_file(@file.name).with_content("rabbit_ha_queues=True") expect(@chef_run).to render_file(@file.name).with_content('rabbit_ha_queues=True')
end end
it "does not have rabbit_host" do it 'does not have rabbit_host' do
expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_host=127.0.0.1") expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_host=127.0.0.1')
end end
it "does not have rabbit_port" do it 'does not have rabbit_port' do
expect(@chef_run).not_to render_file(@file.name).with_content("rabbit_port=5672") expect(@chef_run).not_to render_file(@file.name).with_content('rabbit_port=5672')
end end
end end
describe "qpid" do describe 'qpid' do
before do before do
@file = @chef_run.template "/etc/cinder/cinder.conf" @file = @chef_run.template '/etc/cinder/cinder.conf'
@chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = "qpid" @chef_run.node.set['openstack']['block-storage']['mq']['service_type'] = 'qpid'
end end
it "has qpid_hostname" do it 'has qpid_hostname' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_hostname=127.0.0.1") expect(@chef_run).to render_file(@file.name).with_content('qpid_hostname=127.0.0.1')
end end
it "has qpid_port" do it 'has qpid_port' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_port=5672") expect(@chef_run).to render_file(@file.name).with_content('qpid_port=5672')
end end
it "has qpid_username" do it 'has qpid_username' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_username=") expect(@chef_run).to render_file(@file.name).with_content('qpid_username=')
end end
it "has qpid_password" do it 'has qpid_password' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_password=") expect(@chef_run).to render_file(@file.name).with_content('qpid_password=')
end end
it "has qpid_sasl_mechanisms" do it 'has qpid_sasl_mechanisms' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_sasl_mechanisms=") expect(@chef_run).to render_file(@file.name).with_content('qpid_sasl_mechanisms=')
end end
it "has qpid_reconnect_timeout" do it 'has qpid_reconnect_timeout' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_timeout=0") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_timeout=0')
end end
it "has qpid_reconnect_limit" do it 'has qpid_reconnect_limit' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_limit=0") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_limit=0')
end end
it "has qpid_reconnect_interval_min" do it 'has qpid_reconnect_interval_min' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_min=0") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_min=0')
end end
it "has qpid_reconnect_interval_max" do it 'has qpid_reconnect_interval_max' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval_max=0") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval_max=0')
end end
it "has qpid_reconnect_interval" do it 'has qpid_reconnect_interval' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect_interval=0") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect_interval=0')
end end
it "has qpid_reconnect" do it 'has qpid_reconnect' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_reconnect=true") expect(@chef_run).to render_file(@file.name).with_content('qpid_reconnect=true')
end end
it "has qpid_heartbeat" do it 'has qpid_heartbeat' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_heartbeat=60") expect(@chef_run).to render_file(@file.name).with_content('qpid_heartbeat=60')
end end
it "has qpid_protocol" do it 'has qpid_protocol' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_protocol=tcp") expect(@chef_run).to render_file(@file.name).with_content('qpid_protocol=tcp')
end end
it "has qpid_tcp_nodelay" do it 'has qpid_tcp_nodelay' do
expect(@chef_run).to render_file(@file.name).with_content("qpid_tcp_nodelay=true") expect(@chef_run).to render_file(@file.name).with_content('qpid_tcp_nodelay=true')
end end
end end
end end
describe "/var/lock/cinder" do describe '/var/lock/cinder' do
before do before do
@dir = @chef_run.directory "/var/lock/cinder" @dir = @chef_run.directory '/var/lock/cinder'
end end
it "has proper owner" do it 'has proper owner' do
expect(@dir.owner).to eq("cinder") expect(@dir.owner).to eq('cinder')
expect(@dir.group).to eq("cinder") expect(@dir.group).to eq('cinder')
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @dir.mode)).to eq "700" expect(sprintf('%o', @dir.mode)).to eq '700'
end end
end end

View File

@ -2,7 +2,7 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::default" do describe 'openstack-block-storage::default' do
end end

View File

@ -2,85 +2,85 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::identity_registration" do describe 'openstack-block-storage::identity_registration' do
before do before do
block_storage_stubs block_storage_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-block-storage::identity_registration" @chef_run.converge 'openstack-block-storage::identity_registration'
end end
it "registers cinder volume service" do it 'registers cinder volume service' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Cinder Volume Service" 'Register Cinder Volume Service'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_name => "cinder", service_name: 'cinder',
:service_type => "volume", service_type: 'volume',
:service_description => "Cinder Volume Service", service_description: 'Cinder Volume Service',
:endpoint_region => "RegionOne", endpoint_region: 'RegionOne',
:endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:action => [:create_service] action: [:create_service]
) )
end end
it "registers cinder volume endpoint" do it 'registers cinder volume endpoint' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Cinder Volume Endpoint" 'Register Cinder Volume Endpoint'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_name => "cinder", service_name: 'cinder',
:service_type => "volume", service_type: 'volume',
:service_description => "Cinder Volume Service", service_description: 'Cinder Volume Service',
:endpoint_region => "RegionOne", endpoint_region: 'RegionOne',
:endpoint_adminurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_adminurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:endpoint_internalurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_internalurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:endpoint_publicurl => "http://127.0.0.1:8776/v1/%(tenant_id)s", endpoint_publicurl: 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:action => [:create_endpoint] action: [:create_endpoint]
) )
end end
it "registers service user" do it 'registers service user' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Cinder Service User" 'Register Cinder Service User'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:tenant_name => "service", tenant_name: 'service',
:user_name => "cinder", user_name: 'cinder',
:user_pass => "cinder-pass", user_pass: 'cinder-pass',
:user_enabled => true, user_enabled: true,
:action => [:create_user] action: [:create_user]
) )
end end
it "grants admin role to service user for service tenant" do it 'grants admin role to service user for service tenant' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Grant service Role to Cinder Service User for Cinder Service Tenant" 'Grant service Role to Cinder Service User for Cinder Service Tenant'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:tenant_name => "service", tenant_name: 'service',
:user_name => "cinder", user_name: 'cinder',
:role_name => "admin", role_name: 'admin',
:action => [:grant_role] action: [:grant_role]
) )
end end
end end

View File

@ -2,47 +2,47 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::scheduler" do describe 'openstack-block-storage::scheduler' do
before { block_storage_stubs } before { block_storage_stubs }
describe "opensuse" do describe 'opensuse' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-block-storage::scheduler" @chef_run.converge 'openstack-block-storage::scheduler'
end end
it "installs cinder scheduler packages" do it 'installs cinder scheduler packages' do
expect(@chef_run).to upgrade_package "openstack-cinder-scheduler" expect(@chef_run).to upgrade_package 'openstack-cinder-scheduler'
end end
it "does not upgrade stevedore" do it 'does not upgrade stevedore' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).not_to upgrade_python_pip "stevedore" expect(chef_run).not_to upgrade_python_pip 'stevedore'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysql" expect(@chef_run).to upgrade_package 'python-mysql'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysql" expect(chef_run).not_to upgrade_package 'python-mysql'
end end
it "starts cinder scheduler" do it 'starts cinder scheduler' do
expect(@chef_run).to start_service "openstack-cinder-scheduler" expect(@chef_run).to start_service 'openstack-cinder-scheduler'
end end
it "starts cinder scheduler on boot" do it 'starts cinder scheduler on boot' do
expect(@chef_run).to enable_service "openstack-cinder-scheduler" expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
end end
end end
end end

View File

@ -2,58 +2,58 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::scheduler" do describe 'openstack-block-storage::scheduler' do
before { block_storage_stubs } before { block_storage_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-block-storage::scheduler" @chef_run.converge 'openstack-block-storage::scheduler'
end end
it "installs cinder scheduler packages" do it 'installs cinder scheduler packages' do
expect(@chef_run).to upgrade_package "openstack-cinder" expect(@chef_run).to upgrade_package 'openstack-cinder'
end end
it "does not upgrade stevedore" do it 'does not upgrade stevedore' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).not_to upgrade_python_pip "stevedore" expect(chef_run).not_to upgrade_python_pip 'stevedore'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "MySQL-python" expect(@chef_run).to upgrade_package 'MySQL-python'
end end
it "installs db2 python packages if explicitly told" do it 'installs db2 python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "db2" node.set['openstack']['db']['volume']['db_type'] = 'db2'
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(chef_run).to upgrade_package pkg expect(chef_run).to upgrade_package pkg
end end
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "MySQL-python" expect(chef_run).not_to upgrade_package 'MySQL-python'
end end
it "starts cinder scheduler" do it 'starts cinder scheduler' do
expect(@chef_run).to start_service "openstack-cinder-scheduler" expect(@chef_run).to start_service 'openstack-cinder-scheduler'
end end
it "starts cinder scheduler on boot" do it 'starts cinder scheduler on boot' do
expect(@chef_run).to enable_service "openstack-cinder-scheduler" expect(@chef_run).to enable_service 'openstack-cinder-scheduler'
end end
end end
end end

View File

@ -2,71 +2,71 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::scheduler" do describe 'openstack-block-storage::scheduler' do
before { block_storage_stubs } before { block_storage_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
@chef_run.converge "openstack-block-storage::scheduler" @chef_run.converge 'openstack-block-storage::scheduler'
end end
expect_runs_openstack_common_logging_recipe expect_runs_openstack_common_logging_recipe
it "doesn't run logging recipe" do it 'does not run logging recipe' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).not_to include_recipe "openstack-common::logging" expect(chef_run).not_to include_recipe 'openstack-common::logging'
end end
it "installs cinder scheduler packages" do it 'installs cinder scheduler packages' do
expect(@chef_run).to upgrade_package "cinder-scheduler" expect(@chef_run).to upgrade_package 'cinder-scheduler'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysqldb" expect(@chef_run).to upgrade_package 'python-mysqldb'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysqldb" expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
it "starts cinder scheduler" do it 'starts cinder scheduler' do
expect(@chef_run).to start_service "cinder-scheduler" expect(@chef_run).to start_service 'cinder-scheduler'
end end
it "starts cinder scheduler on boot" do it 'starts cinder scheduler on boot' do
expect(@chef_run).to enable_service "cinder-scheduler" expect(@chef_run).to enable_service 'cinder-scheduler'
end end
it "doesn't run logging recipe" do it 'does not run logging recipe' do
expect(@chef_run).to enable_service "cinder-scheduler" expect(@chef_run).to enable_service 'cinder-scheduler'
end end
it "doesn't setup cron when no metering" do it 'does not setup cron when no metering' do
expect(@chef_run.cron("cinder-volume-usage-audit")).to be_nil expect(@chef_run.cron('cinder-volume-usage-audit')).to be_nil
end end
it "creates cron metering default" do it 'creates cron metering default' do
::Chef::Recipe.any_instance.stub(:search) ::Chef::Recipe.any_instance.stub(:search)
.with(:node, "roles:os-block-storage-scheduler") .with(:node, 'roles:os-block-storage-scheduler')
.and_return([OpenStruct.new(:name => "fauxhai.local")]) .and_return([OpenStruct.new(name: 'fauxhai.local')])
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["metering"] = true n.set['openstack']['metering'] = true
end end
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
cron = chef_run.cron "cinder-volume-usage-audit" cron = chef_run.cron 'cinder-volume-usage-audit'
bin_str = "/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log" bin_str = '/usr/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log'
expect(cron.command).to match(/#{bin_str}/) expect(cron.command).to match(/#{bin_str}/)
crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'], crontests = [[:minute, '00'], [:hour, '*'], [:day, '*'],
[:weekday, '*'], [:month, '*'], [:user, 'cinder']] [:weekday, '*'], [:month, '*'], [:user, 'cinder']]
@ -76,27 +76,27 @@ describe "openstack-block-storage::scheduler" do
expect(cron.action).to include :create expect(cron.action).to include :create
end end
it "creates cron metering custom" do it 'creates cron metering custom' do
crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'], crontests = [[:minute, '50'], [:hour, '23'], [:day, '6'],
[:weekday, '5'], [:month, '11'], [:user, 'foobar']] [:weekday, '5'], [:month, '11'], [:user, 'foobar']]
::Chef::Recipe.any_instance.stub(:search) ::Chef::Recipe.any_instance.stub(:search)
.with(:node, "roles:os-block-storage-scheduler") .with(:node, 'roles:os-block-storage-scheduler')
.and_return([OpenStruct.new(:name => "foobar")]) .and_return([OpenStruct.new(name: 'foobar')])
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["metering"] = true n.set['openstack']['metering'] = true
crontests.each do |k, v| crontests.each do |k, v|
n.set["openstack"]["block-storage"]["cron"][k.to_s] = v n.set['openstack']['block-storage']['cron'][k.to_s] = v
end end
n.set["openstack"]["block-storage"]["user"] = "foobar" n.set['openstack']['block-storage']['user'] = 'foobar'
end end
chef_run.converge "openstack-block-storage::scheduler" chef_run.converge 'openstack-block-storage::scheduler'
cron = chef_run.cron "cinder-volume-usage-audit" cron = chef_run.cron 'cinder-volume-usage-audit'
crontests.each do |k, v| crontests.each do |k, v|
expect(cron.send(k)).to eq v expect(cron.send(k)).to eq v
end end
expect(cron.action).to include :delete expect(cron.action).to include :delete
end end
expect_creates_cinder_conf "service[cinder-scheduler]", "cinder", "cinder" expect_creates_cinder_conf 'service[cinder-scheduler]', 'cinder', 'cinder'
end end
end end

View File

@ -2,87 +2,87 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require "chefspec" require 'chefspec'
require "chefspec/berkshelf" require 'chefspec/berkshelf'
require "chef/application" require 'chef/application'
require_relative "support/matcher" require_relative 'support/matcher'
::LOG_LEVEL = :fatal ::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = { ::OPENSUSE_OPTS = {
:platform => "opensuse", platform: 'opensuse',
:version => "12.3", version: '12.3',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
::REDHAT_OPTS = { ::REDHAT_OPTS = {
:platform => "redhat", platform: 'redhat',
:version => "6.3", version: '6.3',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
::UBUNTU_OPTS = { ::UBUNTU_OPTS = {
:platform => "ubuntu", platform: 'ubuntu',
:version => "12.04", version: '12.04',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
def block_storage_stubs def block_storage_stubs # rubocop:disable MethodLength
::Chef::Recipe.any_instance.stub(:rabbit_servers) ::Chef::Recipe.any_instance.stub(:rabbit_servers)
.and_return "1.1.1.1:5672,2.2.2.2:5672" .and_return '1.1.1.1:5672,2.2.2.2:5672'
::Chef::Recipe.any_instance.stub(:get_password).and_return '' ::Chef::Recipe.any_instance.stub(:get_password).and_return ''
::Chef::Recipe.any_instance.stub(:secret) ::Chef::Recipe.any_instance.stub(:secret)
.with("secrets", "openstack_identity_bootstrap_token") .with('secrets', 'openstack_identity_bootstrap_token')
.and_return "bootstrap-token" .and_return 'bootstrap-token'
::Chef::Recipe.any_instance.stub(:get_password) ::Chef::Recipe.any_instance.stub(:get_password)
.with("user", "guest") .with('user', 'guest')
.and_return "rabbit-pass" .and_return 'rabbit-pass'
::Chef::Recipe.any_instance.stub(:get_password) ::Chef::Recipe.any_instance.stub(:get_password)
.with("service", "openstack-block-storage") .with('service', 'openstack-block-storage')
.and_return "cinder-pass" .and_return 'cinder-pass'
::Chef::Application.stub(:fatal!) ::Chef::Application.stub(:fatal!)
end end
def expect_runs_openstack_common_logging_recipe def expect_runs_openstack_common_logging_recipe
it "runs logging recipe if node attributes say to" do it 'runs logging recipe if node attributes say to' do
expect(@chef_run).to include_recipe "openstack-common::logging" expect(@chef_run).to include_recipe 'openstack-common::logging'
end end
end end
def expect_creates_cinder_conf(service, user, group, action = :restart) def expect_creates_cinder_conf(service, user, group, action = :restart) # rubocop:disable MethodLength
describe "cinder.conf" do describe 'cinder.conf' do
before do before do
@file = @chef_run.template "/etc/cinder/cinder.conf" @file = @chef_run.template '/etc/cinder/cinder.conf'
end end
it "has proper owner" do it 'has proper owner' do
expect(@file.owner).to eq(user) expect(@file.owner).to eq(user)
expect(@file.group).to eq(group) expect(@file.group).to eq(group)
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "644" expect(sprintf('%o', @file.mode)).to eq '644'
end end
it "notifies service restart" do it 'notifies service restart' do
expect(@file).to notify(service).to(action) expect(@file).to notify(service).to(action)
end end
end end
end end
def expect_creates_policy_json(service, user, group, action = :restart) def expect_creates_policy_json(service, user, group, action = :restart) # rubocop:disable MethodLength
describe "policy.json" do describe 'policy.json' do
before do before do
@file = @chef_run.template "/etc/cinder/policy.json" @file = @chef_run.template '/etc/cinder/policy.json'
end end
it "has proper owner" do it 'has proper owner' do
expect(@file.owner).to eq(user) expect(@file.owner).to eq(user)
expect(@file.group).to eq(group) expect(@file.group).to eq(group)
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "644" expect(sprintf('%o', @file.mode)).to eq '644'
end end
it "notifies service restart" do it 'notifies service restart' do
expect(@file).to notify(service).to(action) expect(@file).to notify(service).to(action)
end end
end end

View File

@ -2,66 +2,66 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::volume" do describe 'openstack-block-storage::volume' do
before { block_storage_stubs } before { block_storage_stubs }
describe "opensuse" do describe 'opensuse' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-block-storage::volume" @chef_run.converge 'openstack-block-storage::volume'
end end
it "installs cinder volume packages" do it 'installs cinder volume packages' do
expect(@chef_run).to upgrade_package "openstack-cinder-volume" expect(@chef_run).to upgrade_package 'openstack-cinder-volume'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysql" expect(@chef_run).to upgrade_package 'python-mysql'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysql" expect(chef_run).not_to upgrade_package 'python-mysql'
end end
it "installs cinder iscsi packages" do it 'installs cinder iscsi packages' do
expect(@chef_run).to upgrade_package "tgt" expect(@chef_run).to upgrade_package 'tgt'
end end
it "starts cinder volume" do it 'starts cinder volume' do
expect(@chef_run).to start_service "openstack-cinder-volume" expect(@chef_run).to start_service 'openstack-cinder-volume'
end end
it "starts cinder volume on boot" do it 'starts cinder volume on boot' do
expected = "openstack-cinder-volume" expected = 'openstack-cinder-volume'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
it "starts iscsi target on boot" do it 'starts iscsi target on boot' do
expect(@chef_run).to enable_service "tgtd" expect(@chef_run).to enable_service 'tgtd'
end end
it "installs nfs packages" do it 'installs nfs packages' do
chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "nfs-utils" expect(chef_run).to upgrade_package 'nfs-utils'
expect(chef_run).not_to upgrade_package "nfs-utils-lib" expect(chef_run).not_to upgrade_package 'nfs-utils-lib'
end end
it "has opensuse include" do it 'has opensuse include' do
file = "/etc/tgt/targets.conf" file = '/etc/tgt/targets.conf'
expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
end end
end end
end end

View File

@ -2,73 +2,73 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::volume" do describe 'openstack-block-storage::volume' do
before { block_storage_stubs } before { block_storage_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-block-storage::volume" @chef_run.converge 'openstack-block-storage::volume'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "MySQL-python" expect(@chef_run).to upgrade_package 'MySQL-python'
end end
it "installs db2 python packages if explicitly told" do it 'installs db2 python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "db2" node.set['openstack']['db']['volume']['db_type'] = 'db2'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg| ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(chef_run).to upgrade_package pkg expect(chef_run).to upgrade_package pkg
end end
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "MySQL-python" expect(chef_run).not_to upgrade_package 'MySQL-python'
end end
it "installs cinder iscsi packages" do it 'installs cinder iscsi packages' do
expect(@chef_run).to upgrade_package "scsi-target-utils" expect(@chef_run).to upgrade_package 'scsi-target-utils'
end end
it "starts cinder volume" do it 'starts cinder volume' do
expect(@chef_run).to start_service "openstack-cinder-volume" expect(@chef_run).to start_service 'openstack-cinder-volume'
end end
it "starts cinder volume on boot" do it 'starts cinder volume on boot' do
expected = "openstack-cinder-volume" expected = 'openstack-cinder-volume'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
it "starts iscsi target on boot" do it 'starts iscsi target on boot' do
expect(@chef_run).to enable_service "tgtd" expect(@chef_run).to enable_service 'tgtd'
end end
it "installs nfs packages" do it 'installs nfs packages' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "nfs-utils" expect(chef_run).to upgrade_package 'nfs-utils'
expect(chef_run).to upgrade_package "nfs-utils-lib" expect(chef_run).to upgrade_package 'nfs-utils-lib'
end end
it "has redhat include" do it 'has redhat include' do
file = "/etc/tgt/targets.conf" file = '/etc/tgt/targets.conf'
expect(@chef_run).to render_file(file).with_content("include /var/lib/cinder/volumes/*") expect(@chef_run).to render_file(file).with_content('include /var/lib/cinder/volumes/*')
expect(@chef_run).not_to render_file(file).with_content("include /etc/tgt/conf.d/*.conf") expect(@chef_run).not_to render_file(file).with_content('include /etc/tgt/conf.d/*.conf')
end end
end end
end end

View File

@ -2,189 +2,189 @@
# #
# Cookbook Name:: openstack-block-storage # Cookbook Name:: openstack-block-storage
require_relative "spec_helper" require_relative 'spec_helper'
describe "openstack-block-storage::volume" do describe 'openstack-block-storage::volume' do
before { block_storage_stubs } before { block_storage_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["syslog"]["use"] = true n.set['openstack']['block-storage']['syslog']['use'] = true
end end
@chef_run.converge "openstack-block-storage::volume" @chef_run.converge 'openstack-block-storage::volume'
end end
expect_runs_openstack_common_logging_recipe expect_runs_openstack_common_logging_recipe
it "doesn't run logging recipe" do it 'does not run logging recipe' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).not_to include_recipe "openstack-common::logging" expect(chef_run).not_to include_recipe 'openstack-common::logging'
end end
it "installs cinder volume packages" do it 'installs cinder volume packages' do
expect(@chef_run).to upgrade_package "cinder-volume" expect(@chef_run).to upgrade_package 'cinder-volume'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package "python-mysqldb" expect(@chef_run).to upgrade_package 'python-mysqldb'
end end
it "installs postgresql python packages if explicitly told" do it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" node.set['openstack']['db']['volume']['db_type'] = 'postgresql'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "python-psycopg2" expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package "python-mysqldb" expect(chef_run).not_to upgrade_package 'python-mysqldb'
end end
it "installs cinder iscsi packages" do it 'installs cinder iscsi packages' do
expect(@chef_run).to upgrade_package "tgt" expect(@chef_run).to upgrade_package 'tgt'
end end
it "installs nfs packages" do it 'installs nfs packages' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to upgrade_package "nfs-common" expect(chef_run).to upgrade_package 'nfs-common'
end end
it "creates the nfs mount point" do it 'creates the nfs mount point' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.nfs.NetAppDirect7modeNfsDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
expect(chef_run).to create_directory "/mnt/cinder-volumes" expect(chef_run).to create_directory '/mnt/cinder-volumes'
end end
it "configures netapp dfm password" do it 'configures netapp dfm password' do
::Chef::Recipe.any_instance.stub(:get_password).with("service", "netapp") ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'netapp')
.and_return "netapp-pass" .and_return 'netapp-pass'
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.netapp.iscsi.NetAppISCSIDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
n = chef_run.node["openstack"]["block-storage"]["netapp"]["dfm_password"] n = chef_run.node['openstack']['block-storage']['netapp']['dfm_password']
expect(n).to eq "netapp-pass" expect(n).to eq 'netapp-pass'
end end
it "configures rbd password" do it 'configures rbd password' do
::Chef::Recipe.any_instance.stub(:get_password).with("service", "rbd") ::Chef::Recipe.any_instance.stub(:get_password).with('service', 'rbd')
.and_return "rbd-pass" .and_return 'rbd-pass'
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.RBDDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.RBDDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
n = chef_run.node["openstack"]["block-storage"]["rbd_secret_uuid"] n = chef_run.node['openstack']['block-storage']['rbd_secret_uuid']
expect(n).to eq "rbd-pass" expect(n).to eq 'rbd-pass'
end end
it "configures storewize private key" do it 'configures storewize private key' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
end end
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
san_key = chef_run.file chef_run.node["openstack"]["block-storage"]["san"]["san_private_key"] san_key = chef_run.file chef_run.node['openstack']['block-storage']['san']['san_private_key']
expect(san_key.mode).to eq('0400') expect(san_key.mode).to eq('0400')
end end
it "configures storewize with iscsi" do it 'configures storewize with iscsi' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "iSCSI" n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI'
end end
conf = "/etc/cinder/cinder.conf" conf = '/etc/cinder/cinder.conf'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
# Test that the FC specific options are not set when connected via iSCSI # Test that the FC specific options are not set when connected via iSCSI
expect(chef_run).not_to render_file(conf).with_content("storwize_svc_multipath_enabled") expect(chef_run).not_to render_file(conf).with_content('storwize_svc_multipath_enabled')
end end
it "configures storewize with fc" do it 'configures storewize with fc' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.storwize_svc.StorwizeSVCDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.storwize_svc.StorwizeSVCDriver'
n.set["openstack"]["block-storage"]["storwize"]["storwize_svc_connection_protocol"] = "FC" n.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'FC'
end end
conf = "/etc/cinder/cinder.conf" conf = '/etc/cinder/cinder.conf'
chef_run.converge "openstack-block-storage::volume" chef_run.converge 'openstack-block-storage::volume'
# Test that the iSCSI specific options are not set when connected via FC # Test that the iSCSI specific options are not set when connected via FC
expect(chef_run).not_to render_file(conf).with_content("storwize_svc_iscsi_chap_enabled") expect(chef_run).not_to render_file(conf).with_content('storwize_svc_iscsi_chap_enabled')
end end
it "starts cinder volume" do it 'starts cinder volume' do
expect(@chef_run).to start_service "cinder-volume" expect(@chef_run).to start_service 'cinder-volume'
end end
it "starts cinder volume on boot" do it 'starts cinder volume on boot' do
expect(@chef_run).to enable_service "cinder-volume" expect(@chef_run).to enable_service 'cinder-volume'
end end
expect_creates_cinder_conf "service[cinder-volume]", "cinder", "cinder" expect_creates_cinder_conf 'service[cinder-volume]', 'cinder', 'cinder'
it "starts iscsi target on boot" do it 'starts iscsi target on boot' do
expect(@chef_run).to enable_service "tgt" expect(@chef_run).to enable_service 'tgt'
end end
describe "targets.conf" do describe 'targets.conf' do
before do before do
@file = @chef_run.template "/etc/tgt/targets.conf" @file = @chef_run.template '/etc/tgt/targets.conf'
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "600" expect(sprintf('%o', @file.mode)).to eq '600'
end end
it "notifies iscsi restart" do it 'notifies iscsi restart' do
expect(@file).to notify("service[iscsitarget]").to(:restart) expect(@file).to notify('service[iscsitarget]').to(:restart)
end end
it "has ubuntu include" do it 'has ubuntu include' do
expect(@chef_run).to render_file(@file.name).with_content("include /etc/tgt/conf.d/*.conf") expect(@chef_run).to render_file(@file.name).with_content('include /etc/tgt/conf.d/*.conf')
expect(@chef_run).not_to render_file(@file.name).with_content("include /var/lib/cinder/volumes/*") expect(@chef_run).not_to render_file(@file.name).with_content('include /var/lib/cinder/volumes/*')
end end
end end
describe "create_vg" do describe 'create_vg' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n| @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
n.set["openstack"]["block-storage"]["volume"]["driver"] = "cinder.volume.drivers.lvm.LVMISCSIDriver" n.set['openstack']['block-storage']['volume']['driver'] = 'cinder.volume.drivers.lvm.LVMISCSIDriver'
n.set["openstack"]["block-storage"]["volume"]["create_volume_group"] = true n.set['openstack']['block-storage']['volume']['create_volume_group'] = true
end end
stub_command("vgs cinder-volumes").and_return(false) stub_command('vgs cinder-volumes').and_return(false)
@filename = "/etc/init.d/cinder-group-active" @filename = '/etc/init.d/cinder-group-active'
@chef_run.converge "openstack-block-storage::volume" @chef_run.converge 'openstack-block-storage::volume'
@file = @chef_run.template(@filename) @file = @chef_run.template(@filename)
end end
it "cinder vg active" do it 'cinder vg active' do
expect(@chef_run).to enable_service "cinder-group-active" expect(@chef_run).to enable_service 'cinder-group-active'
end end
it "create volume group" do it 'create volume group' do
volume_size = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group_size"] volume_size = @chef_run.node['openstack']['block-storage']['volume']['volume_group_size']
seek_count = volume_size.to_i * 1024 seek_count = volume_size.to_i * 1024
group_name = @chef_run.node["openstack"]["block-storage"]["volume"]["volume_group"] group_name = @chef_run.node['openstack']['block-storage']['volume']['volume_group']
path = @chef_run.node["openstack"]["block-storage"]["volume"]["state_path"] path = @chef_run.node['openstack']['block-storage']['volume']['state_path']
vg_file = "#{path}/#{group_name}.img" vg_file = "#{path}/#{group_name}.img"
cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})" cmd = "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate cinder-volumes $(losetup --show -f #{vg_file})"
expect(@chef_run).to run_execute(cmd) expect(@chef_run).to run_execute(cmd)
end end
it "notifies cinder group active start" do it 'notifies cinder group active start' do
expect(@file).to notify("service[cinder-group-active]").to(:start) expect(@file).to notify('service[cinder-group-active]').to(:start)
end end
it "creates cinder group active template file" do it 'creates cinder group active template file' do
expect(@chef_run).to create_template(@filename) expect(@chef_run).to create_template(@filename)
end end
end end