Added systemd unit, style and lint fixes for chefdk

- cinder-group-active is still SysV, but can and will start via systemd if
  coaxed to do so.
- Style and lint fixes for newer chefdk
- Removed ancient Gemfile
- Rewrote metadata.rb for readability

Change-Id: I4c26aea78220eb20fc4e5e964af93414855df5f6
This commit is contained in:
Samuel Cassiba 2017-07-11 06:19:21 -07:00
parent ae28e74793
commit d2ff4496bb
12 changed files with 55 additions and 43 deletions

View File

@ -1,15 +1,15 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-02-23 16:58:21 +0100 using RuboCop version 0.39.0.
# on 2017-08-02 02:05:24 -0400 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'recipes/identity_registration.rb'
# Offense count: 18
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 178
# Offense count: 4
# Configuration parameters: EnforcedStyle, SupportedStyles.

15
Gemfile
View File

@ -1,15 +0,0 @@
## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE
## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE
## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS
# encoding: UTF-8
source 'https://rubygems.org'
gem 'chef', '~> 11.18.6'
gem 'json', '<= 1.7.7' # chef 11 dependency
gem 'berkshelf', '~> 3.2.1'
gem 'hashie', '~> 2.0'
gem 'chefspec', '~> 4.0.0'
gem 'rspec', '~> 3.0.0'
gem 'foodcritic', '~> 4.0'
gem 'rubocop', '~> 0.29.1'

View File

@ -0,0 +1,18 @@
[Unit]
SourcePath=/etc/init.d/cinder-group-active
Description=LSB: cinder volume group active script
After=remote-fs.target
After=network-online.target
After=systemd-journald-dev-log.socket
Wants=network-online.target
[Service]
Type=oneshot
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=true
ExecStart=/etc/init.d/cinder-group-active start
ExecStop=/etc/init.d/cinder-group-active stop

View File

@ -1,20 +1,22 @@
# encoding: UTF-8
name 'openstack-block-storage'
maintainer 'openstack-chef'
name 'openstack-block-storage'
maintainer 'Chef OpenStack'
maintainer_email 'openstack-dev@lists.openstack.org'
issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
source_url 'https://github.com/openstack/cookbook-openstack-block-storage' if respond_to?(:source_url)
license 'Apache 2.0'
description 'The OpenStack Advanced Volume Management service Cinder.'
license 'Apache 2.0'
description 'The OpenStack Advanced Volume Management service Cinder.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '15.0.0'
version '15.0.0'
%w(ubuntu redhat centos).each do |os|
supports os
end
depends 'apt', '~> 5.0'
depends 'openstack-common', '>= 15.0.0'
depends 'openstack-identity', '>= 15.0.0'
depends 'openstack-image', '>= 15.0.0'
depends 'openstackclient'
depends 'apt', '~> 5.0'
issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
source_url 'https://github.com/openstack/cookbook-openstack-block-storage' if respond_to?(:source_url)
chef_version '>= 12.5' if respond_to?(:chef_version)

View File

@ -57,6 +57,6 @@ if node['openstack']['block-storage']['policyfile_url']
source node['openstack']['block-storage']['policyfile_url']
owner node['openstack']['block-storage']['user']
group node['openstack']['block-storage']['group']
mode 00644
mode 0o0644
end
end

View File

@ -59,7 +59,7 @@ auth_url = identity_admin_endpoint.to_s
directory '/etc/cinder' do
group node['openstack']['block-storage']['group']
owner node['openstack']['block-storage']['user']
mode 00750
mode 0o0750
action :create
end
@ -100,7 +100,7 @@ template '/etc/cinder/cinder.conf' do
cookbook 'openstack-common'
group node['openstack']['block-storage']['group']
owner node['openstack']['block-storage']['user']
mode 00640
mode 0o0640
variables(
service_config: cinder_conf_options
)
@ -119,7 +119,7 @@ directory node['openstack']['block-storage']['conf']['oslo_concurrency']['lock_p
group node['openstack']['block-storage']['group']
owner node['openstack']['block-storage']['user']
recursive true
mode 00755
mode 0o0755
end
if node['openstack']['block-storage']['use_rootwrap']
@ -128,7 +128,7 @@ if node['openstack']['block-storage']['use_rootwrap']
cookbook 'openstack-common'
owner 'root'
group 'root'
mode 00644
mode 0o0644
variables(
service_config: node['openstack']['block-storage']['rootwrap']['conf']
)

View File

@ -68,7 +68,7 @@ end
# RHEL7 doesn't need targets.conf file
template '/etc/tgt/targets.conf' do
source 'targets.conf.erb'
mode 00600
mode 0o0600
notifies :restart, 'service[iscsitarget]', :immediately
not_if { node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7 }
end

View File

@ -41,9 +41,15 @@ when 'file'
not_if "vgs #{vg_name}"
end
cookbook_file '/etc/systemd/system/cinder-group-active.service' do
source 'cinder-group-active.service'
mode '0644'
action :create_if_missing
end
template '/etc/init.d/cinder-group-active' do
source 'cinder-group-active.erb'
mode '755'
mode '0755'
variables(
volume_name: vg_name,
volume_file: vg_file

View File

@ -45,7 +45,8 @@ describe 'openstack-block-storage::api' do
expect(chef_run).to create_remote_file('/etc/cinder/policy.json').with(
user: 'cinder',
group: 'cinder',
mode: 00644)
mode: 0o0644
)
end
end
end

View File

@ -28,7 +28,7 @@ describe 'openstack-block-storage::cinder-common' do
expect(chef_run).to create_directory(dir.name).with(
owner: 'cinder',
group: 'cinder',
mode: 00750
mode: 0o0750
)
end
end
@ -46,7 +46,7 @@ describe 'openstack-block-storage::cinder-common' do
expect(chef_run).to create_template(file.name).with(
owner: 'cinder',
group: 'cinder',
mode: 00640
mode: 0o0640
)
end
@ -185,7 +185,7 @@ describe 'openstack-block-storage::cinder-common' do
expect(chef_run).to create_directory(dir.name).with(
user: 'cinder',
group: 'cinder',
mode: 00755
mode: 0o0755
)
end
end
@ -197,7 +197,7 @@ describe 'openstack-block-storage::cinder-common' do
expect(chef_run).to create_template(file.name).with(
user: 'root',
group: 'root',
mode: 0644
mode: 0o644
)
end

View File

@ -98,7 +98,7 @@ shared_examples 'creates_cinder_conf' do |service, user, group, action = :restar
expect(chef_run).to create_template(file.name).with(
user: user,
group: group,
mode: 0640
mode: 0o640
)
end

View File

@ -54,7 +54,7 @@ describe 'openstack-block-storage::volume' do
it 'should create the targets.conf' do
expect(chef_run).to create_template(file.name).with(
mode: 0600
mode: 0o600
)
end