Browse Source

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
Samuel Cassiba 1 year ago
parent
commit
d2ff4496bb

+ 5
- 5
.rubocop_todo.yml View File

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

+ 0
- 15
Gemfile View File

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

+ 18
- 0
files/default/cinder-group-active.service View File

@@ -0,0 +1,18 @@
1
+[Unit]
2
+SourcePath=/etc/init.d/cinder-group-active
3
+Description=LSB: cinder volume group active script
4
+After=remote-fs.target
5
+After=network-online.target
6
+After=systemd-journald-dev-log.socket
7
+Wants=network-online.target
8
+
9
+[Service]
10
+Type=oneshot
11
+Restart=no
12
+TimeoutSec=5min
13
+IgnoreSIGPIPE=no
14
+KillMode=process
15
+GuessMainPID=no
16
+RemainAfterExit=true
17
+ExecStart=/etc/init.d/cinder-group-active start
18
+ExecStop=/etc/init.d/cinder-group-active stop

+ 11
- 9
metadata.rb View File

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

+ 1
- 1
recipes/api.rb View File

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

+ 4
- 4
recipes/cinder-common.rb View File

@@ -59,7 +59,7 @@ auth_url = identity_admin_endpoint.to_s
59 59
 directory '/etc/cinder' do
60 60
   group node['openstack']['block-storage']['group']
61 61
   owner node['openstack']['block-storage']['user']
62
-  mode 00750
62
+  mode 0o0750
63 63
   action :create
64 64
 end
65 65
 
@@ -100,7 +100,7 @@ template '/etc/cinder/cinder.conf' do
100 100
   cookbook 'openstack-common'
101 101
   group node['openstack']['block-storage']['group']
102 102
   owner node['openstack']['block-storage']['user']
103
-  mode 00640
103
+  mode 0o0640
104 104
   variables(
105 105
     service_config: cinder_conf_options
106 106
   )
@@ -119,7 +119,7 @@ directory node['openstack']['block-storage']['conf']['oslo_concurrency']['lock_p
119 119
   group node['openstack']['block-storage']['group']
120 120
   owner node['openstack']['block-storage']['user']
121 121
   recursive true
122
-  mode 00755
122
+  mode 0o0755
123 123
 end
124 124
 
125 125
 if node['openstack']['block-storage']['use_rootwrap']
@@ -128,7 +128,7 @@ if node['openstack']['block-storage']['use_rootwrap']
128 128
     cookbook 'openstack-common'
129 129
     owner 'root'
130 130
     group 'root'
131
-    mode 00644
131
+    mode 0o0644
132 132
     variables(
133 133
       service_config: node['openstack']['block-storage']['rootwrap']['conf']
134 134
     )

+ 1
- 1
recipes/volume.rb View File

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

+ 7
- 1
recipes/volume_driver_lvm.rb View File

@@ -41,9 +41,15 @@ when 'file'
41 41
     not_if "vgs #{vg_name}"
42 42
   end
43 43
 
44
+  cookbook_file '/etc/systemd/system/cinder-group-active.service' do
45
+    source 'cinder-group-active.service'
46
+    mode '0644'
47
+    action :create_if_missing
48
+  end
49
+
44 50
   template '/etc/init.d/cinder-group-active' do
45 51
     source 'cinder-group-active.erb'
46
-    mode '755'
52
+    mode '0755'
47 53
     variables(
48 54
       volume_name: vg_name,
49 55
       volume_file: vg_file

+ 2
- 1
spec/api_spec.rb View File

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

+ 4
- 4
spec/cinder_common_spec.rb View File

@@ -28,7 +28,7 @@ describe 'openstack-block-storage::cinder-common' do
28 28
         expect(chef_run).to create_directory(dir.name).with(
29 29
           owner: 'cinder',
30 30
           group: 'cinder',
31
-          mode: 00750
31
+          mode: 0o0750
32 32
         )
33 33
       end
34 34
     end
@@ -46,7 +46,7 @@ describe 'openstack-block-storage::cinder-common' do
46 46
         expect(chef_run).to create_template(file.name).with(
47 47
           owner: 'cinder',
48 48
           group: 'cinder',
49
-          mode: 00640
49
+          mode: 0o0640
50 50
         )
51 51
       end
52 52
 
@@ -185,7 +185,7 @@ describe 'openstack-block-storage::cinder-common' do
185 185
         expect(chef_run).to create_directory(dir.name).with(
186 186
           user: 'cinder',
187 187
           group: 'cinder',
188
-          mode: 00755
188
+          mode: 0o0755
189 189
         )
190 190
       end
191 191
     end
@@ -197,7 +197,7 @@ describe 'openstack-block-storage::cinder-common' do
197 197
         expect(chef_run).to create_template(file.name).with(
198 198
           user: 'root',
199 199
           group: 'root',
200
-          mode: 0644
200
+          mode: 0o644
201 201
         )
202 202
       end
203 203
 

+ 1
- 1
spec/spec_helper.rb View File

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

+ 1
- 1
spec/volume_spec.rb View File

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

Loading…
Cancel
Save