Browse Source

block-storage refactor for Pike and Chef 13

- deprecated postgresql support
- dropped apt cookbook dependency
- deprecated node.foo.bar method access for node['foo']['bar'] bracket syntax
- implemented foodcritic and cookstyle corrections
- migrated cinder api to a Chef-managed config
- deprecated cinder-group-active service, as it is no longer needed and gets in
  the way of functionality
- added lvm cookbook dependency for better pv/vg handling

Implements blueprint modern-chef

Change-Id: Id248c9267af6750c871487bc8b577aa2011a782a
Samuel Cassiba 1 year ago
parent
commit
c18919e533

+ 11
- 10
Berksfile View File

@@ -1,13 +1,14 @@
1
-source "https://supermarket.chef.io"
1
+source 'https://supermarket.chef.io'
2 2
 
3
-metadata
3
+%w(image identity common).each do |cookbook|
4
+  if Dir.exist?("../cookbook-openstack-#{cookbook}")
5
+    cookbook "openstack-#{cookbook}", path: "../cookbook-openstack-#{cookbook}"
6
+  else
7
+    cookbook "openstack-#{cookbook}", github: "openstack/cookbook-openstack-#{cookbook}"
8
+  end
9
+end
4 10
 
5
-cookbook "openstack-image",
6
-  github: "openstack/cookbook-openstack-image"
7
-cookbook "openstack-identity",
8
-  github: "openstack/cookbook-openstack-identity"
9
-cookbook "openstack-common",
10
-  github: "openstack/cookbook-openstack-common"
11
-cookbook "openstackclient",
12
-  github: "cloudbau/cookbook-openstackclient"
11
+cookbook 'openstackclient',
12
+  github: 'cloudbau/cookbook-openstackclient'
13 13
 
14
+metadata

+ 176
- 0
LICENSE View File

@@ -0,0 +1,176 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.
176
+

+ 15
- 16
Rakefile View File

@@ -1,40 +1,39 @@
1
-task default: ["test"]
1
+task default: ['test']
2 2
 
3
-task :test => [:syntax, :lint, :unit]
3
+task test: [:syntax, :lint, :unit]
4 4
 
5
-desc "Vendor the cookbooks in the Berksfile"
5
+desc 'Vendor the cookbooks in the Berksfile'
6 6
 task :berks_prep do
7
-  sh %{chef exec berks vendor}
7
+  sh %(chef exec berks vendor)
8 8
 end
9 9
 
10
-desc "Run FoodCritic (syntax) tests"
10
+desc 'Run FoodCritic (syntax) tests'
11 11
 task :syntax do
12
-  sh %{chef exec foodcritic --exclude spec -f any .}
12
+  sh %(chef exec foodcritic --exclude spec -f any .)
13 13
 end
14 14
 
15
-desc "Run RuboCop (lint) tests"
15
+desc 'Run RuboCop (lint) tests'
16 16
 task :lint do
17
-  sh %{chef exec cookstyle}
17
+  sh %(chef exec cookstyle)
18 18
 end
19 19
 
20
-desc "Run RSpec (unit) tests"
21
-task :unit => :berks_prep do
22
-  sh %{chef exec rspec --format documentation}
20
+desc 'Run RSpec (unit) tests'
21
+task unit: :berks_prep do
22
+  sh %(chef exec rspec --format documentation)
23 23
 end
24 24
 
25
-desc "Remove the berks-cookbooks directory and the Berksfile.lock"
25
+desc 'Remove the berks-cookbooks directory and the Berksfile.lock'
26 26
 task :clean do
27 27
   rm_rf [
28 28
     'berks-cookbooks',
29
-    'Berksfile.lock'
29
+    'Berksfile.lock',
30 30
   ]
31 31
 end
32 32
 
33
-desc "All-in-One Neutron build Infra using Common task"
33
+desc 'All-in-One Neutron build Infra using Common task'
34 34
 task :integration do
35 35
   # Use the common integration task
36 36
   sh %(wget -nv -t 3 -O Rakefile-Common https://raw.githubusercontent.com/openstack/cookbook-openstack-common/master/Rakefile)
37 37
   load './Rakefile-Common'
38
-  Rake::Task["common_integration"].invoke
38
+  Rake::Task['common_integration'].invoke
39 39
 end
40
-

+ 15
- 5
attributes/default.rb View File

@@ -71,6 +71,16 @@ default['openstack']['block-storage']['volume']['block_devices'] = nil
71 71
 default['openstack']['block-storage']['user'] = 'cinder'
72 72
 default['openstack']['block-storage']['group'] = 'cinder'
73 73
 
74
+# Cinder WSGI app SSL settings
75
+default['openstack']['block-storage']['ssl']['enabled'] = false
76
+default['openstack']['block-storage']['ssl']['certfile'] = ''
77
+default['openstack']['block-storage']['ssl']['chainfile'] = ''
78
+default['openstack']['block-storage']['ssl']['keyfile'] = ''
79
+default['openstack']['block-storage']['ssl']['ca_certs_path'] = ''
80
+default['openstack']['block-storage']['ssl']['cert_required'] = false
81
+default['openstack']['block-storage']['ssl']['protocol'] = ''
82
+default['openstack']['block-storage']['ssl']['ciphers'] = ''
83
+
74 84
 case node['platform_family']
75 85
 when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
76 86
   # operating system user and group names
@@ -79,14 +89,14 @@ when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
79 89
     'cinder_common_packages' => ['openstack-cinder'],
80 90
     'cinder_api_packages' => ['openstack-cinder'],
81 91
     'cinder_api_service' => 'openstack-cinder-api',
82
-    'cinder_volume_packages' => ['qemu-img-ev'],
92
+    'cinder_volume_packages' => ['qemu-img-ev', 'scsi-target-utils'],
83 93
     'cinder_volume_service' => 'openstack-cinder-volume',
84 94
     'cinder_scheduler_packages' => [],
85 95
     'cinder_scheduler_service' => 'openstack-cinder-scheduler',
86 96
     'cinder_backup_packages' => [],
87 97
     'cinder_backup_service' => 'openstack-cinder-backup',
88
-    'cinder_iscsitarget_packages' => ['targetcli'],
89
-    'cinder_iscsitarget_service' => 'target',
98
+    'cinder_iscsitarget_packages' => ['targetcli', 'dbus-python'],
99
+    'cinder_iscsitarget_service' => 'tgtd',
90 100
     'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
91 101
     'cinder_nfs_packages' => ['nfs-utils', 'nfs-utils-lib'],
92 102
     'cinder_emc_packages' => ['pywbem'],
@@ -101,7 +111,7 @@ when 'debian'
101 111
     'cinder_common_packages' => ['cinder-common'],
102 112
     'cinder_api_packages' => ['cinder-api'],
103 113
     'cinder_api_service' => 'cinder-api',
104
-    'cinder_volume_packages' => ['cinder-volume', 'qemu-utils'],
114
+    'cinder_volume_packages' => ['cinder-volume', 'qemu-utils', 'thin-provisioning-tools'],
105 115
     'cinder_volume_service' => 'cinder-volume',
106 116
     'cinder_scheduler_packages' => ['cinder-scheduler'],
107 117
     'cinder_scheduler_service' => 'cinder-scheduler',
@@ -115,7 +125,7 @@ when 'debian'
115 125
     'cinder_svc_packages' => ['sysfsutils'],
116 126
     'cinder_lvm_packages' => ['lvm2'],
117 127
     'cinder_flashsystem_packages' => ['sysfsutils'],
118
-    'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'",
128
+    'package_overrides' => '',
119 129
   }
120 130
 end
121 131
 

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

@@ -1,18 +0,0 @@
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

+ 1
- 0
files/default/cinder_tgt.conf View File

@@ -0,0 +1 @@
1
+include /var/lib/cinder/volumes/*

+ 3
- 2
metadata.rb View File

@@ -1,7 +1,7 @@
1 1
 name             'openstack-block-storage'
2 2
 maintainer       'Chef OpenStack'
3 3
 maintainer_email 'openstack-dev@lists.openstack.org'
4
-license          'Apache 2.0'
4
+license          'Apache-2.0'
5 5
 description      'The OpenStack Advanced Volume Management service Cinder.'
6 6
 long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7 7
 version          '16.0.0'
@@ -15,7 +15,8 @@ depends 'openstack-identity', '>= 16.0.0'
15 15
 depends 'openstack-image', '>= 16.0.0'
16 16
 depends 'openstackclient'
17 17
 
18
-depends 'apt', '~> 5.0'
18
+depends 'lvm'
19
+depends 'selinux'
19 20
 
20 21
 issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
21 22
 source_url 'https://github.com/openstack/cookbook-openstack-block-storage' if respond_to?(:source_url)

+ 26
- 4
recipes/api.rb View File

@@ -27,6 +27,7 @@ end
27 27
 
28 28
 include_recipe 'openstack-block-storage::cinder-common'
29 29
 
30
+bind_service = node['openstack']['bind_service']['all']['block-storage']
30 31
 platform_options = node['openstack']['block-storage']['platform']
31 32
 
32 33
 platform_options['cinder_api_packages'].each do |pkg|
@@ -43,10 +44,6 @@ node['openstack']['db']['python_packages'][db_type].each do |pkg|
43 44
   end
44 45
 end
45 46
 
46
-# Todo(jr): Runs via wsgi in apache2 now, need to find a nice way to
47
-# trigger apache2 restart. Also disable the default installed wsgi
48
-# service and use our template based setup
49
-
50 47
 execute 'cinder-manage db sync' do
51 48
   user node['openstack']['block-storage']['user']
52 49
   group node['openstack']['block-storage']['group']
@@ -60,3 +57,28 @@ if node['openstack']['block-storage']['policyfile_url']
60 57
     mode 0o0644
61 58
   end
62 59
 end
60
+
61
+# remove the cinder-wsgi.conf automatically generated from package
62
+apache_config 'cinder-wsgi' do
63
+  enable false
64
+end
65
+
66
+web_app 'cinder-api' do
67
+  template 'wsgi-template.conf.erb'
68
+  daemon_process 'cinder-wsgi'
69
+  server_host bind_service['host']
70
+  server_port bind_service['port']
71
+  server_entry '/usr/bin/cinder-wsgi'
72
+  log_dir node['apache']['log_dir']
73
+  run_dir node['apache']['run_dir']
74
+  user node['openstack']['block-storage']['user']
75
+  group node['openstack']['block-storage']['group']
76
+  use_ssl node['openstack']['block-storage']['ssl']['enabled']
77
+  cert_file node['openstack']['block-storage']['ssl']['certfile']
78
+  chain_file node['openstack']['block-storage']['ssl']['chainfile']
79
+  key_file node['openstack']['block-storage']['ssl']['keyfile']
80
+  ca_certs_path node['openstack']['block-storage']['ssl']['ca_certs_path']
81
+  cert_required node['openstack']['block-storage']['ssl']['cert_required']
82
+  protocol node['openstack']['block-storage']['ssl']['protocol']
83
+  ciphers node['openstack']['block-storage']['ssl']['ciphers']
84
+end

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

@@ -67,7 +67,7 @@ node.default['openstack']['block-storage']['conf'].tap do |conf|
67 67
   conf['DEFAULT']['my_ip'] = cinder_api_bind_address
68 68
   conf['DEFAULT']['glance_api_servers'] = glance_api_endpoint.to_s
69 69
   conf['DEFAULT']['osapi_volume_listen'] = cinder_api_bind_address
70
-  conf['DEFAULT']['osapi_volume_listen_port'] = cinder_api_bind.port
70
+  conf['DEFAULT']['osapi_volume_listen_port'] = cinder_api_bind['port']
71 71
   conf['keystone_authtoken']['auth_uri'] = auth_uri
72 72
   conf['keystone_authtoken']['auth_url'] = auth_url
73 73
 end

+ 21
- 10
recipes/identity_registration.rb View File

@@ -55,14 +55,14 @@ connection_params = {
55 55
   openstack_domain_name:    admin_domain,
56 56
 }
57 57
 
58
-# Register VolumeV2 Service
58
+# Register Volume Service
59 59
 openstack_service service_name do
60 60
   type service_type
61 61
   connection_params connection_params
62 62
 end
63 63
 
64 64
 interfaces.each do |interface, res|
65
-  # Register VolumeV2 Endpoints
65
+  # Register Volume Endpoints
66 66
   openstack_endpoint service_type do
67 67
     service_name service_name
68 68
     interface interface.to_s
@@ -72,6 +72,23 @@ interfaces.each do |interface, res|
72 72
   end
73 73
 end
74 74
 
75
+# Workaround to enable Volume support in Horizon
76
+# this may break in future releases of chef-client
77
+openstack_service 'cinderv3' do
78
+  type 'volumev3'
79
+  connection_params connection_params
80
+end
81
+
82
+interfaces.each do |interface, res|
83
+  openstack_endpoint 'volumev3' do
84
+    service_name 'cinderv3'
85
+    interface interface.to_s
86
+    url res[:url].to_s.gsub('/v2', '/v3')
87
+    region region
88
+    connection_params connection_params
89
+  end
90
+end
91
+
75 92
 # Register Service Project
76 93
 openstack_project service_project_name do
77 94
   connection_params connection_params
@@ -81,14 +98,8 @@ end
81 98
 openstack_user service_user do
82 99
   project_name service_project_name
83 100
   domain_name service_domain_name
84
-  password service_pass
85
-  connection_params connection_params
86
-end
87
-
88
-## Grant Service role to Service User for Service Tenant ##
89
-openstack_user service_user do
90 101
   role_name service_role
91
-  project_name service_project_name
102
+  password service_pass
92 103
   connection_params connection_params
93
-  action :grant_role
104
+  action [:create, :grant_role]
94 105
 end

+ 1
- 2
recipes/volume.rb View File

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

+ 10
- 26
recipes/volume_driver_lvm.rb View File

@@ -35,38 +35,22 @@ when 'file'
35 35
   vg_file = "#{node['openstack']['block-storage']['conf']['DEFAULT']['state_path']}/#{vg_name}.img"
36 36
 
37 37
   # create volume group
38
-  execute 'Create Cinder volume group' do
38
+  execute 'Create Cinder loopback file' do
39 39
     command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})"
40 40
     action :run
41
-    not_if "vgs #{vg_name}"
42
-  end
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
-
50
-  template '/etc/init.d/cinder-group-active' do
51
-    source 'cinder-group-active.erb'
52
-    mode '0755'
53
-    variables(
54
-      volume_name: vg_name,
55
-      volume_file: vg_file
56
-    )
57
-    notifies :start, 'service[cinder-group-active]', :immediately
41
+    not_if "pvs | grep -c #{vg_name}"
58 42
   end
43
+when 'block_devices'
44
+  block_devices = node['openstack']['block-storage']['volume']['block_devices']
59 45
 
60
-  service 'cinder-group-active' do
61
-    service_name 'cinder-group-active'
62
-    action [:enable, :start]
46
+  lvm_physical_volume block_devices do
47
+    action :create
48
+    not_if "pvs | grep -c #{block_devices}"
63 49
   end
64 50
 
65
-when 'block_devices'
66
-  block_devices = node['openstack']['block-storage']['volume']['block_devices']
67
-  execute 'Create Cinder volume group with block devices' do
68
-    command "pvcreate #{block_devices}; vgcreate #{vg_name} #{block_devices}"
69
-    action :run
51
+  lvm_volume_group vg_name do
52
+    physical_volumes [block_devices]
53
+    wipe_signatures true
70 54
     not_if "vgs #{vg_name}"
71 55
   end
72 56
 end

+ 0
- 7
spec/api-redhat_spec.rb View File

@@ -19,12 +19,5 @@ describe 'openstack-block-storage::api' do
19 19
     it 'upgrades mysql python package' do
20 20
       expect(chef_run).to upgrade_package 'MySQL-python'
21 21
     end
22
-
23
-    it 'upgrades postgresql python packages if explicitly told' do
24
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
25
-
26
-      expect(chef_run).to upgrade_package 'python-psycopg2'
27
-      expect(chef_run).not_to upgrade_package 'MySQL-python'
28
-    end
29 22
   end
30 23
 end

+ 0
- 7
spec/api_spec.rb View File

@@ -22,13 +22,6 @@ describe 'openstack-block-storage::api' do
22 22
       expect(chef_run).to upgrade_package('python-mysqldb')
23 23
     end
24 24
 
25
-    it 'upgrades postgresql python packages if explicitly told' do
26
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
27
-
28
-      expect(chef_run).to upgrade_package('python-psycopg2')
29
-      expect(chef_run).not_to upgrade_package('python-mysqldb')
30
-    end
31
-
32 25
     it 'runs db migrations' do
33 26
       expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder')
34 27
     end

+ 0
- 7
spec/backup-redhat_spec.rb View File

@@ -28,13 +28,6 @@ describe 'openstack-block-storage::backup' do
28 28
       it 'upgrades mysql python package' do
29 29
         expect(chef_run).to upgrade_package 'MySQL-python'
30 30
       end
31
-
32
-      it 'upgrades postgresql python packages if explicitly told' do
33
-        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
34
-
35
-        expect(chef_run).to upgrade_package 'python-psycopg2'
36
-        expect(chef_run).not_to upgrade_package 'MySQL-python'
37
-      end
38 31
     end
39 32
   end
40 33
 end

+ 0
- 7
spec/backup_spec.rb View File

@@ -32,13 +32,6 @@ describe 'openstack-block-storage::backup' do
32 32
       it 'upgrades mysql python package' do
33 33
         expect(chef_run).to upgrade_package 'python-mysqldb'
34 34
       end
35
-
36
-      it 'upgrades postgresql python packages if explicitly told' do
37
-        node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
38
-
39
-        expect(chef_run).to upgrade_package 'python-psycopg2'
40
-        expect(chef_run).not_to upgrade_package 'python-mysqldb'
41
-      end
42 35
     end
43 36
   end
44 37
 end

+ 22
- 10
spec/identity_registration_spec.rb View File

@@ -23,6 +23,7 @@ describe 'openstack-block-storage::identity_registration' do
23 23
     service_type = 'volumev2'
24 24
     service_user = 'cinder'
25 25
     url = 'http://127.0.0.1:8776/v2/%(tenant_id)s'
26
+    url_v3 = 'http://127.0.0.1:8776/v3/%(tenant_id)s'
26 27
     region = 'RegionOne'
27 28
     project_name = 'service'
28 29
     role_name = 'service'
@@ -46,6 +47,15 @@ describe 'openstack-block-storage::identity_registration' do
46 47
       )
47 48
     end
48 49
 
50
+    it 'registers cinderv3 service' do
51
+      expect(chef_run).to create_openstack_service(
52
+        'cinderv3'
53
+      ).with(
54
+        connection_params: connection_params,
55
+        type: 'volumev3'
56
+      )
57
+    end
58
+
49 59
     context "registers #{service_name} endpoint" do
50 60
       %w(admin internal public).each do |interface|
51 61
         it "#{interface} endpoint with default values" do
@@ -59,6 +69,18 @@ describe 'openstack-block-storage::identity_registration' do
59 69
             connection_params: connection_params
60 70
           )
61 71
         end
72
+
73
+        it "volumev3 #{interface} endpoint with default values" do
74
+          expect(chef_run).to create_openstack_endpoint(
75
+            'volumev3'
76
+          ).with(
77
+            service_name: 'cinderv3',
78
+            # interface: interface,
79
+            url: url_v3,
80
+            region: region,
81
+            connection_params: connection_params
82
+          )
83
+        end
62 84
       end
63 85
 
64 86
       it 'with custom region override' do
@@ -74,16 +96,6 @@ describe 'openstack-block-storage::identity_registration' do
74 96
         service_user
75 97
       ).with(
76 98
         domain_name: domain_name,
77
-        project_name: project_name,
78
-        password: password,
79
-        connection_params: connection_params
80
-      )
81
-    end
82
-
83
-    it do
84
-      expect(chef_run).to grant_role_openstack_user(
85
-        service_user
86
-      ).with(
87 99
         project_name: project_name,
88 100
         role_name: role_name,
89 101
         password: password,

+ 0
- 7
spec/scheduler-redhat_spec.rb View File

@@ -27,12 +27,5 @@ describe 'openstack-block-storage::scheduler' do
27 27
     it 'upgrades mysql python package' do
28 28
       expect(chef_run).to upgrade_package 'MySQL-python'
29 29
     end
30
-
31
-    it 'upgrades postgresql python packages if explicitly told' do
32
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
33
-
34
-      expect(chef_run).to upgrade_package 'python-psycopg2'
35
-      expect(chef_run).not_to upgrade_package 'MySQL-python'
36
-    end
37 30
   end
38 31
 end

+ 0
- 7
spec/scheduler_spec.rb View File

@@ -29,12 +29,5 @@ describe 'openstack-block-storage::scheduler' do
29 29
     it 'upgrades mysql python package' do
30 30
       expect(chef_run).to upgrade_package 'python-mysqldb'
31 31
     end
32
-
33
-    it 'upgrades postgresql python packages if explicitly told' do
34
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
35
-
36
-      expect(chef_run).to upgrade_package 'python-psycopg2'
37
-      expect(chef_run).not_to upgrade_package 'python-mysqldb'
38
-    end
39 32
   end
40 33
 end

+ 3
- 1
spec/spec_helper.rb View File

@@ -12,7 +12,7 @@ require 'chef/application'
12 12
 LOG_LEVEL = :fatal
13 13
 REDHAT_OPTS = {
14 14
   platform: 'redhat',
15
-  version: '7.1',
15
+  version: '7.3',
16 16
   log_level: LOG_LEVEL,
17 17
 }.freeze
18 18
 UBUNTU_OPTS = {
@@ -58,6 +58,8 @@ shared_context 'block-storage-stubs' do
58 58
     allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
59 59
       .with('block-storage')
60 60
       .and_return('rabbit://guest:mypass@127.0.0.1:5672')
61
+    stub_command('/usr/sbin/httpd -t').and_return(true)
62
+    stub_command('/usr/sbin/apache2 -t').and_return(true)
61 63
     allow(Chef::Application).to receive(:fatal!)
62 64
   end
63 65
 end

+ 1
- 8
spec/volume-redhat_spec.rb View File

@@ -16,13 +16,6 @@ describe 'openstack-block-storage::volume' do
16 16
       expect(chef_run).to upgrade_package('MySQL-python')
17 17
     end
18 18
 
19
-    it 'upgrades postgresql python packages if explicitly told' do
20
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
21
-
22
-      expect(chef_run).to upgrade_package('python-psycopg2')
23
-      expect(chef_run).not_to upgrade_package('MySQL-python')
24
-    end
25
-
26 19
     it 'upgrades qemu-img-ev package' do
27 20
       expect(chef_run).to upgrade_package('qemu-img-ev')
28 21
     end
@@ -41,7 +34,7 @@ describe 'openstack-block-storage::volume' do
41 34
 
42 35
     context 'ISCSI' do
43 36
       it 'starts iscsi target on boot' do
44
-        expect(chef_run).to enable_service('target')
37
+        expect(chef_run).to enable_service('iscsitarget')
45 38
       end
46 39
     end
47 40
   end

+ 4
- 7
spec/volume_spec.rb View File

@@ -22,6 +22,10 @@ describe 'openstack-block-storage::volume' do
22 22
       expect(chef_run).to upgrade_package 'qemu-utils'
23 23
     end
24 24
 
25
+    it 'upgrades thin provisioning tools package' do
26
+      expect(chef_run).to upgrade_package 'thin-provisioning-tools'
27
+    end
28
+
25 29
     it 'starts cinder volume' do
26 30
       expect(chef_run).to start_service 'cinder-volume'
27 31
     end
@@ -38,13 +42,6 @@ describe 'openstack-block-storage::volume' do
38 42
       expect(chef_run).to upgrade_package 'python-mysqldb'
39 43
     end
40 44
 
41
-    it 'upgrades postgresql python packages if explicitly told' do
42
-      node.set['openstack']['db']['block-storage']['service_type'] = 'postgresql'
43
-
44
-      expect(chef_run).to upgrade_package 'python-psycopg2'
45
-      expect(chef_run).not_to upgrade_package 'python-mysqldb'
46
-    end
47
-
48 45
     it 'upgrades cinder iscsi package' do
49 46
       expect(chef_run).to upgrade_package 'tgt'
50 47
     end

+ 0
- 48
templates/default/cinder-group-active.erb View File

@@ -1,48 +0,0 @@
1
-#!/bin/sh
2
-<%= node["openstack"]["block-storage"]["custom_template_banner"] %>
3
-#
4
-# cinder volume group active script
5
-#
6
-# only support start action
7
-# chkconfig: - 98 02
8
-#
9
-### BEGIN INIT INFO
10
-# Provides: cinder-group-active
11
-# Required-Start: $remote_fs $network $syslog
12
-# Required-Stop: $remote_fs $syslog
13
-# Default-Start: 2 3 4 5
14
-# Default-Stop: 0 1 6
15
-# Short-Description: cinder volume group active script
16
-### END INIT INFO
17
-
18
-<% if %w{rhel}.include? node.platform_family %>
19
-. /etc/rc.d/init.d/functions
20
-<% end %>
21
-
22
-start()
23
-{
24
-  vgs <%= @volume_name %> > /dev/null 2>&1
25
-  if [ $? -ne 0 ]; then
26
-    echo -n "Activating cinder volume group ..."
27
-    vgcreate <%= @volume_name %> $(losetup --show -f <%= @volume_file %>)
28
-    <% if %w{rhel}.include? node.platform_family %>
29
-    success
30
-    echo
31
-    <% elsif %w{debian}.include? node.platform_family %>
32
-    echo "SUCCESS"
33
-    <% end %>
34
-  fi
35
-}
36
-
37
-RETVAL=0
38
-
39
-case "$1" in
40
-  start)
41
-    start
42
-    ;;
43
-  *)
44
-    echo "Usage: $0 {start}"
45
-    RETVAL=1
46
-esac
47
-
48
-exit $RETVAL

+ 3
- 3
templates/default/targets.conf.erb View File

@@ -1,9 +1,9 @@
1 1
 <%= node["openstack"]["block-storage"]["custom_template_banner"] %>
2 2
 
3
-<% if %w(rhel).include?(node["platform_family"]) %>
4
-include <%= node['openstack']['block-storage']['conf']['DEFAULT']['volumes_dir'] %>/*
3
+<% if node['platform_family'].include?('rhel') %>
4
+include <%= node['openstack']['block-storage']['conf']['DEFAULT']['state_path'] %>/volumes/*
5 5
 <% end %>
6
-<% if %w(debian).include?(node["platform_family"]) %>
6
+<% if node['platform_family'].include?('debian') %>
7 7
 include /etc/tgt/conf.d/*.conf
8 8
 <% end %>
9 9
 default-driver iscsi

+ 42
- 0
templates/default/wsgi-template.conf.erb View File

@@ -0,0 +1,42 @@
1
+<%= node["openstack"]["compute"]["custom_template_banner"] %>
2
+
3
+Listen <%= @params[:server_host] %>:<%= @params[:server_port] %>
4
+
5
+<VirtualHost <%= @params[:server_host] %>:<%= @params[:server_port] %>>
6
+  WSGIDaemonProcess <%= @params[:daemon_process] %> processes=2 threads=10 user=<%= @params[:user] %> group=<%= @params[:group] %> display-name=%{GROUP}
7
+  WSGIProcessGroup <%= @params[:daemon_process] %>
8
+  WSGIScriptAlias / <%= @params[:server_entry] %>
9
+  WSGIApplicationGroup %{GLOBAL}
10
+  WSGIPassAuthorization On
11
+
12
+  <Directory /usr/bin>
13
+    Require all granted
14
+  </Directory>
15
+
16
+  ErrorLogFormat "%{cu}t %M"
17
+  ErrorLog <%= @params[:log_dir] %>/<%= @params[:daemon_process] %>_error.log
18
+  CustomLog <%= @params[:log_dir] %>/<%= @params[:daemon_process] %>_access.log combined
19
+<% if [true, 'true', 'True'].include?(@params[:log_debug]) -%>
20
+  LogLevel debug
21
+<% end -%>
22
+
23
+<% if @params[:use_ssl] -%>
24
+  SSLEngine On
25
+  SSLCertificateFile <%= @params[:cert_file] %>
26
+  SSLCertificateKeyFile <%= @params[:key_file] %>
27
+  SSLCACertificatePath <%= @params[:ca_certs_path] %>
28
+<%   if @params[:chain_file] %>
29
+  SSLCertificateChainFile <%= @params[:chain_file] %>
30
+<%   end -%>
31
+  SSLProtocol <%= @params[:protocol] %>
32
+<%   if @params[:ciphers] -%>
33
+  SSLCipherSuite <%= @params[:ciphers] %>
34
+<%   end -%>
35
+<%   if @params[:cert_required] -%>
36
+  SSLVerifyClient require
37
+<%   end -%>
38
+<% end -%>
39
+</VirtualHost>
40
+
41
+WSGISocketPrefix <%= @params[:run_dir] -%>
42
+

Loading…
Cancel
Save