summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Cassiba <s@cassiba.com>2017-11-26 22:32:21 -0800
committerSamuel Cassiba <s@cassiba.com>2017-12-12 17:34:08 -0800
commitc18919e533b02726cde4219c1579ea7e6d66dc90 (patch)
treecb4e66434d403748d3f7715f3c0eda8365ecacbf
parent54f8d6d9174540debd0659abc2bbe782379f65f4 (diff)
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
Notes
Notes (review): Code-Review+2: Jan Klare <j.klare@cloudbau.de> Workflow+1: Christoph Albers <c.albers@x-ion.de> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 22 Dec 2017 11:48:18 +0000 Reviewed-on: https://review.openstack.org/523031 Project: openstack/cookbook-openstack-block-storage Branch: refs/heads/master
-rw-r--r--Berksfile21
-rw-r--r--LICENSE176
-rw-r--r--Rakefile31
-rw-r--r--attributes/default.rb20
-rw-r--r--files/default/cinder-group-active.service18
-rw-r--r--files/default/cinder_tgt.conf1
-rw-r--r--metadata.rb5
-rw-r--r--recipes/api.rb30
-rw-r--r--recipes/cinder-common.rb2
-rw-r--r--recipes/identity_registration.rb31
-rw-r--r--recipes/volume.rb3
-rw-r--r--recipes/volume_driver_lvm.rb36
-rw-r--r--spec/api-redhat_spec.rb7
-rw-r--r--spec/api_spec.rb7
-rw-r--r--spec/backup-redhat_spec.rb7
-rw-r--r--spec/backup_spec.rb7
-rw-r--r--spec/identity_registration_spec.rb32
-rw-r--r--spec/scheduler-redhat_spec.rb7
-rw-r--r--spec/scheduler_spec.rb7
-rw-r--r--spec/spec_helper.rb4
-rw-r--r--spec/volume-redhat_spec.rb9
-rw-r--r--spec/volume_spec.rb11
-rw-r--r--templates/default/cinder-group-active.erb48
-rw-r--r--templates/default/targets.conf.erb6
-rw-r--r--templates/default/wsgi-template.conf.erb42
25 files changed, 355 insertions, 213 deletions
diff --git a/Berksfile b/Berksfile
index a603520..5d6fe13 100644
--- a/Berksfile
+++ b/Berksfile
@@ -1,13 +1,14 @@
1source "https://supermarket.chef.io" 1source 'https://supermarket.chef.io'
2 2
3metadata 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
9end
4 10
5cookbook "openstack-image", 11cookbook 'openstackclient',
6 github: "openstack/cookbook-openstack-image" 12 github: 'cloudbau/cookbook-openstackclient'
7cookbook "openstack-identity",
8 github: "openstack/cookbook-openstack-identity"
9cookbook "openstack-common",
10 github: "openstack/cookbook-openstack-common"
11cookbook "openstackclient",
12 github: "cloudbau/cookbook-openstackclient"
13 13
14metadata
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68c771a
--- /dev/null
+++ b/LICENSE
@@ -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
diff --git a/Rakefile b/Rakefile
index c9edb13..137cc2f 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,40 +1,39 @@
1task default: ["test"] 1task default: ['test']
2 2
3task :test => [:syntax, :lint, :unit] 3task test: [:syntax, :lint, :unit]
4 4
5desc "Vendor the cookbooks in the Berksfile" 5desc 'Vendor the cookbooks in the Berksfile'
6task :berks_prep do 6task :berks_prep do
7 sh %{chef exec berks vendor} 7 sh %(chef exec berks vendor)
8end 8end
9 9
10desc "Run FoodCritic (syntax) tests" 10desc 'Run FoodCritic (syntax) tests'
11task :syntax do 11task :syntax do
12 sh %{chef exec foodcritic --exclude spec -f any .} 12 sh %(chef exec foodcritic --exclude spec -f any .)
13end 13end
14 14
15desc "Run RuboCop (lint) tests" 15desc 'Run RuboCop (lint) tests'
16task :lint do 16task :lint do
17 sh %{chef exec cookstyle} 17 sh %(chef exec cookstyle)
18end 18end
19 19
20desc "Run RSpec (unit) tests" 20desc 'Run RSpec (unit) tests'
21task :unit => :berks_prep do 21task unit: :berks_prep do
22 sh %{chef exec rspec --format documentation} 22 sh %(chef exec rspec --format documentation)
23end 23end
24 24
25desc "Remove the berks-cookbooks directory and the Berksfile.lock" 25desc 'Remove the berks-cookbooks directory and the Berksfile.lock'
26task :clean do 26task :clean do
27 rm_rf [ 27 rm_rf [
28 'berks-cookbooks', 28 'berks-cookbooks',
29 'Berksfile.lock' 29 'Berksfile.lock',
30 ] 30 ]
31end 31end
32 32
33desc "All-in-One Neutron build Infra using Common task" 33desc 'All-in-One Neutron build Infra using Common task'
34task :integration do 34task :integration do
35 # Use the common integration task 35 # Use the common integration task
36 sh %(wget -nv -t 3 -O Rakefile-Common https://raw.githubusercontent.com/openstack/cookbook-openstack-common/master/Rakefile) 36 sh %(wget -nv -t 3 -O Rakefile-Common https://raw.githubusercontent.com/openstack/cookbook-openstack-common/master/Rakefile)
37 load './Rakefile-Common' 37 load './Rakefile-Common'
38 Rake::Task["common_integration"].invoke 38 Rake::Task['common_integration'].invoke
39end 39end
40
diff --git a/attributes/default.rb b/attributes/default.rb
index e9d0c51..975bb8b 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -71,6 +71,16 @@ default['openstack']['block-storage']['volume']['block_devices'] = nil
71default['openstack']['block-storage']['user'] = 'cinder' 71default['openstack']['block-storage']['user'] = 'cinder'
72default['openstack']['block-storage']['group'] = 'cinder' 72default['openstack']['block-storage']['group'] = 'cinder'
73 73
74# Cinder WSGI app SSL settings
75default['openstack']['block-storage']['ssl']['enabled'] = false
76default['openstack']['block-storage']['ssl']['certfile'] = ''
77default['openstack']['block-storage']['ssl']['chainfile'] = ''
78default['openstack']['block-storage']['ssl']['keyfile'] = ''
79default['openstack']['block-storage']['ssl']['ca_certs_path'] = ''
80default['openstack']['block-storage']['ssl']['cert_required'] = false
81default['openstack']['block-storage']['ssl']['protocol'] = ''
82default['openstack']['block-storage']['ssl']['ciphers'] = ''
83
74case node['platform_family'] 84case node['platform_family']
75when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this 85when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
76 # operating system user and group names 86 # operating system user and group names
@@ -79,14 +89,14 @@ when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this
79 'cinder_common_packages' => ['openstack-cinder'], 89 'cinder_common_packages' => ['openstack-cinder'],
80 'cinder_api_packages' => ['openstack-cinder'], 90 'cinder_api_packages' => ['openstack-cinder'],
81 'cinder_api_service' => 'openstack-cinder-api', 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 'cinder_volume_service' => 'openstack-cinder-volume', 93 'cinder_volume_service' => 'openstack-cinder-volume',
84 'cinder_scheduler_packages' => [], 94 'cinder_scheduler_packages' => [],
85 'cinder_scheduler_service' => 'openstack-cinder-scheduler', 95 'cinder_scheduler_service' => 'openstack-cinder-scheduler',
86 'cinder_backup_packages' => [], 96 'cinder_backup_packages' => [],
87 'cinder_backup_service' => 'openstack-cinder-backup', 97 'cinder_backup_service' => 'openstack-cinder-backup',
88 'cinder_iscsitarget_packages' => ['targetcli'], 98 'cinder_iscsitarget_packages' => ['targetcli', 'dbus-python'],
89 'cinder_iscsitarget_service' => 'target', 99 'cinder_iscsitarget_service' => 'tgtd',
90 'cinder_ceph_packages' => ['python-ceph', 'ceph-common'], 100 'cinder_ceph_packages' => ['python-ceph', 'ceph-common'],
91 'cinder_nfs_packages' => ['nfs-utils', 'nfs-utils-lib'], 101 'cinder_nfs_packages' => ['nfs-utils', 'nfs-utils-lib'],
92 'cinder_emc_packages' => ['pywbem'], 102 'cinder_emc_packages' => ['pywbem'],
@@ -101,7 +111,7 @@ when 'debian'
101 'cinder_common_packages' => ['cinder-common'], 111 'cinder_common_packages' => ['cinder-common'],
102 'cinder_api_packages' => ['cinder-api'], 112 'cinder_api_packages' => ['cinder-api'],
103 'cinder_api_service' => 'cinder-api', 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 'cinder_volume_service' => 'cinder-volume', 115 'cinder_volume_service' => 'cinder-volume',
106 'cinder_scheduler_packages' => ['cinder-scheduler'], 116 'cinder_scheduler_packages' => ['cinder-scheduler'],
107 'cinder_scheduler_service' => 'cinder-scheduler', 117 'cinder_scheduler_service' => 'cinder-scheduler',
@@ -115,7 +125,7 @@ when 'debian'
115 'cinder_svc_packages' => ['sysfsutils'], 125 'cinder_svc_packages' => ['sysfsutils'],
116 'cinder_lvm_packages' => ['lvm2'], 126 'cinder_lvm_packages' => ['lvm2'],
117 'cinder_flashsystem_packages' => ['sysfsutils'], 127 'cinder_flashsystem_packages' => ['sysfsutils'],
118 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", 128 'package_overrides' => '',
119 } 129 }
120end 130end
121 131
diff --git a/files/default/cinder-group-active.service b/files/default/cinder-group-active.service
deleted file mode 100644
index 37cc140..0000000
--- a/files/default/cinder-group-active.service
+++ /dev/null
@@ -1,18 +0,0 @@
1[Unit]
2SourcePath=/etc/init.d/cinder-group-active
3Description=LSB: cinder volume group active script
4After=remote-fs.target
5After=network-online.target
6After=systemd-journald-dev-log.socket
7Wants=network-online.target
8
9[Service]
10Type=oneshot
11Restart=no
12TimeoutSec=5min
13IgnoreSIGPIPE=no
14KillMode=process
15GuessMainPID=no
16RemainAfterExit=true
17ExecStart=/etc/init.d/cinder-group-active start
18ExecStop=/etc/init.d/cinder-group-active stop
diff --git a/files/default/cinder_tgt.conf b/files/default/cinder_tgt.conf
new file mode 100644
index 0000000..444eb00
--- /dev/null
+++ b/files/default/cinder_tgt.conf
@@ -0,0 +1 @@
include /var/lib/cinder/volumes/*
diff --git a/metadata.rb b/metadata.rb
index ae63c31..d10ceb0 100644
--- a/metadata.rb
+++ b/metadata.rb
@@ -1,7 +1,7 @@
1name 'openstack-block-storage' 1name 'openstack-block-storage'
2maintainer 'Chef OpenStack' 2maintainer 'Chef OpenStack'
3maintainer_email 'openstack-dev@lists.openstack.org' 3maintainer_email 'openstack-dev@lists.openstack.org'
4license 'Apache 2.0' 4license 'Apache-2.0'
5description 'The OpenStack Advanced Volume Management service Cinder.' 5description 'The OpenStack Advanced Volume Management service Cinder.'
6long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 6long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7version '16.0.0' 7version '16.0.0'
@@ -15,7 +15,8 @@ depends 'openstack-identity', '>= 16.0.0'
15depends 'openstack-image', '>= 16.0.0' 15depends 'openstack-image', '>= 16.0.0'
16depends 'openstackclient' 16depends 'openstackclient'
17 17
18depends 'apt', '~> 5.0' 18depends 'lvm'
19depends 'selinux'
19 20
20issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url) 21issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url)
21source_url 'https://github.com/openstack/cookbook-openstack-block-storage' if respond_to?(:source_url) 22source_url 'https://github.com/openstack/cookbook-openstack-block-storage' if respond_to?(:source_url)
diff --git a/recipes/api.rb b/recipes/api.rb
index 726c5ce..287ae5f 100644
--- a/recipes/api.rb
+++ b/recipes/api.rb
@@ -27,6 +27,7 @@ end
27 27
28include_recipe 'openstack-block-storage::cinder-common' 28include_recipe 'openstack-block-storage::cinder-common'
29 29
30bind_service = node['openstack']['bind_service']['all']['block-storage']
30platform_options = node['openstack']['block-storage']['platform'] 31platform_options = node['openstack']['block-storage']['platform']
31 32
32platform_options['cinder_api_packages'].each do |pkg| 33platform_options['cinder_api_packages'].each do |pkg|
@@ -43,10 +44,6 @@ node['openstack']['db']['python_packages'][db_type].each do |pkg|
43 end 44 end
44end 45end
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
50execute 'cinder-manage db sync' do 47execute 'cinder-manage db sync' do
51 user node['openstack']['block-storage']['user'] 48 user node['openstack']['block-storage']['user']
52 group node['openstack']['block-storage']['group'] 49 group node['openstack']['block-storage']['group']
@@ -60,3 +57,28 @@ if node['openstack']['block-storage']['policyfile_url']
60 mode 0o0644 57 mode 0o0644
61 end 58 end
62end 59end
60
61# remove the cinder-wsgi.conf automatically generated from package
62apache_config 'cinder-wsgi' do
63 enable false
64end
65
66web_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']
84end
diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb
index 57edc9c..6d5b860 100644
--- a/recipes/cinder-common.rb
+++ b/recipes/cinder-common.rb
@@ -67,7 +67,7 @@ node.default['openstack']['block-storage']['conf'].tap do |conf|
67 conf['DEFAULT']['my_ip'] = cinder_api_bind_address 67 conf['DEFAULT']['my_ip'] = cinder_api_bind_address
68 conf['DEFAULT']['glance_api_servers'] = glance_api_endpoint.to_s 68 conf['DEFAULT']['glance_api_servers'] = glance_api_endpoint.to_s
69 conf['DEFAULT']['osapi_volume_listen'] = cinder_api_bind_address 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 conf['keystone_authtoken']['auth_uri'] = auth_uri 71 conf['keystone_authtoken']['auth_uri'] = auth_uri
72 conf['keystone_authtoken']['auth_url'] = auth_url 72 conf['keystone_authtoken']['auth_url'] = auth_url
73end 73end
diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb
index 6e90f64..20862a6 100644
--- a/recipes/identity_registration.rb
+++ b/recipes/identity_registration.rb
@@ -55,14 +55,14 @@ connection_params = {
55 openstack_domain_name: admin_domain, 55 openstack_domain_name: admin_domain,
56} 56}
57 57
58# Register VolumeV2 Service 58# Register Volume Service
59openstack_service service_name do 59openstack_service service_name do
60 type service_type 60 type service_type
61 connection_params connection_params 61 connection_params connection_params
62end 62end
63 63
64interfaces.each do |interface, res| 64interfaces.each do |interface, res|
65 # Register VolumeV2 Endpoints 65 # Register Volume Endpoints
66 openstack_endpoint service_type do 66 openstack_endpoint service_type do
67 service_name service_name 67 service_name service_name
68 interface interface.to_s 68 interface interface.to_s
@@ -72,6 +72,23 @@ interfaces.each do |interface, res|
72 end 72 end
73end 73end
74 74
75# Workaround to enable Volume support in Horizon
76# this may break in future releases of chef-client
77openstack_service 'cinderv3' do
78 type 'volumev3'
79 connection_params connection_params
80end
81
82interfaces.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
90end
91
75# Register Service Project 92# Register Service Project
76openstack_project service_project_name do 93openstack_project service_project_name do
77 connection_params connection_params 94 connection_params connection_params
@@ -81,14 +98,8 @@ end
81openstack_user service_user do 98openstack_user service_user do
82 project_name service_project_name 99 project_name service_project_name
83 domain_name service_domain_name 100 domain_name service_domain_name
84 password service_pass
85 connection_params connection_params
86end
87
88## Grant Service role to Service User for Service Tenant ##
89openstack_user service_user do
90 role_name service_role 101 role_name service_role
91 project_name service_project_name 102 password service_pass
92 connection_params connection_params 103 connection_params connection_params
93 action :grant_role 104 action [:create, :grant_role]
94end 105end
diff --git a/recipes/volume.rb b/recipes/volume.rb
index 6132f3e..01d81f5 100644
--- a/recipes/volume.rb
+++ b/recipes/volume.rb
@@ -65,10 +65,9 @@ service 'iscsitarget' do
65 action :enable 65 action :enable
66end 66end
67 67
68# RHEL7 doesn't need targets.conf file
69template '/etc/tgt/targets.conf' do 68template '/etc/tgt/targets.conf' do
70 source 'targets.conf.erb' 69 source 'targets.conf.erb'
71 mode 0o0600 70 mode 0o0600
72 notifies :restart, 'service[iscsitarget]', :immediately 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
74end 73end
diff --git a/recipes/volume_driver_lvm.rb b/recipes/volume_driver_lvm.rb
index f12afae..db9dd2b 100644
--- a/recipes/volume_driver_lvm.rb
+++ b/recipes/volume_driver_lvm.rb
@@ -35,38 +35,22 @@ when 'file'
35 vg_file = "#{node['openstack']['block-storage']['conf']['DEFAULT']['state_path']}/#{vg_name}.img" 35 vg_file = "#{node['openstack']['block-storage']['conf']['DEFAULT']['state_path']}/#{vg_name}.img"
36 36
37 # create volume group 37 # create volume group
38 execute 'Create Cinder volume group' do 38 execute 'Create Cinder loopback file' do
39 command "dd if=/dev/zero of=#{vg_file} bs=1M seek=#{seek_count} count=0; vgcreate #{vg_name} $(losetup --show -f #{vg_file})" 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 action :run 40 action :run
41 not_if "vgs #{vg_name}" 41 not_if "pvs | grep -c #{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
58 end 42 end
43when 'block_devices'
44 block_devices = node['openstack']['block-storage']['volume']['block_devices']
59 45
60 service 'cinder-group-active' do 46 lvm_physical_volume block_devices do
61 service_name 'cinder-group-active' 47 action :create
62 action [:enable, :start] 48 not_if "pvs | grep -c #{block_devices}"
63 end 49 end
64 50
65when 'block_devices' 51 lvm_volume_group vg_name do
66 block_devices = node['openstack']['block-storage']['volume']['block_devices'] 52 physical_volumes [block_devices]
67 execute 'Create Cinder volume group with block devices' do 53 wipe_signatures true
68 command "pvcreate #{block_devices}; vgcreate #{vg_name} #{block_devices}"
69 action :run
70 not_if "vgs #{vg_name}" 54 not_if "vgs #{vg_name}"
71 end 55 end
72end 56end
diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb
index d0ef802..11f73b6 100644
--- a/spec/api-redhat_spec.rb
+++ b/spec/api-redhat_spec.rb
@@ -19,12 +19,5 @@ describe 'openstack-block-storage::api' do
19 it 'upgrades mysql python package' do 19 it 'upgrades mysql python package' do
20 expect(chef_run).to upgrade_package 'MySQL-python' 20 expect(chef_run).to upgrade_package 'MySQL-python'
21 end 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 end 22 end
30end 23end
diff --git a/spec/api_spec.rb b/spec/api_spec.rb
index 366a2bb..13f9897 100644
--- a/spec/api_spec.rb
+++ b/spec/api_spec.rb
@@ -22,13 +22,6 @@ describe 'openstack-block-storage::api' do
22 expect(chef_run).to upgrade_package('python-mysqldb') 22 expect(chef_run).to upgrade_package('python-mysqldb')
23 end 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 it 'runs db migrations' do 25 it 'runs db migrations' do
33 expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder') 26 expect(chef_run).to run_execute('cinder-manage db sync').with(user: 'cinder', group: 'cinder')
34 end 27 end
diff --git a/spec/backup-redhat_spec.rb b/spec/backup-redhat_spec.rb
index 3e46c41..7fc940b 100644
--- a/spec/backup-redhat_spec.rb
+++ b/spec/backup-redhat_spec.rb
@@ -28,13 +28,6 @@ describe 'openstack-block-storage::backup' do
28 it 'upgrades mysql python package' do 28 it 'upgrades mysql python package' do
29 expect(chef_run).to upgrade_package 'MySQL-python' 29 expect(chef_run).to upgrade_package 'MySQL-python'
30 end 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 end 31 end
39 end 32 end
40end 33end
diff --git a/spec/backup_spec.rb b/spec/backup_spec.rb
index d8ff358..ed44776 100644
--- a/spec/backup_spec.rb
+++ b/spec/backup_spec.rb
@@ -32,13 +32,6 @@ describe 'openstack-block-storage::backup' do
32 it 'upgrades mysql python package' do 32 it 'upgrades mysql python package' do
33 expect(chef_run).to upgrade_package 'python-mysqldb' 33 expect(chef_run).to upgrade_package 'python-mysqldb'
34 end 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 end 35 end
43 end 36 end
44end 37end
diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb
index 95e2315..c0cdfec 100644
--- a/spec/identity_registration_spec.rb
+++ b/spec/identity_registration_spec.rb
@@ -23,6 +23,7 @@ describe 'openstack-block-storage::identity_registration' do
23 service_type = 'volumev2' 23 service_type = 'volumev2'
24 service_user = 'cinder' 24 service_user = 'cinder'
25 url = 'http://127.0.0.1:8776/v2/%(tenant_id)s' 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 region = 'RegionOne' 27 region = 'RegionOne'
27 project_name = 'service' 28 project_name = 'service'
28 role_name = 'service' 29 role_name = 'service'
@@ -46,6 +47,15 @@ describe 'openstack-block-storage::identity_registration' do
46 ) 47 )
47 end 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 context "registers #{service_name} endpoint" do 59 context "registers #{service_name} endpoint" do
50 %w(admin internal public).each do |interface| 60 %w(admin internal public).each do |interface|
51 it "#{interface} endpoint with default values" do 61 it "#{interface} endpoint with default values" do
@@ -59,6 +69,18 @@ describe 'openstack-block-storage::identity_registration' do
59 connection_params: connection_params 69 connection_params: connection_params
60 ) 70 )
61 end 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 end 84 end
63 85
64 it 'with custom region override' do 86 it 'with custom region override' do
@@ -75,16 +97,6 @@ describe 'openstack-block-storage::identity_registration' do
75 ).with( 97 ).with(
76 domain_name: domain_name, 98 domain_name: domain_name,
77 project_name: project_name, 99 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 project_name: project_name,
88 role_name: role_name, 100 role_name: role_name,
89 password: password, 101 password: password,
90 connection_params: connection_params 102 connection_params: connection_params
diff --git a/spec/scheduler-redhat_spec.rb b/spec/scheduler-redhat_spec.rb
index edd0c00..0c2ff2f 100644
--- a/spec/scheduler-redhat_spec.rb
+++ b/spec/scheduler-redhat_spec.rb
@@ -27,12 +27,5 @@ describe 'openstack-block-storage::scheduler' do
27 it 'upgrades mysql python package' do 27 it 'upgrades mysql python package' do
28 expect(chef_run).to upgrade_package 'MySQL-python' 28 expect(chef_run).to upgrade_package 'MySQL-python'
29 end 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 end 30 end
38end 31end
diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb
index 3b60a7c..2cefe34 100644
--- a/spec/scheduler_spec.rb
+++ b/spec/scheduler_spec.rb
@@ -29,12 +29,5 @@ describe 'openstack-block-storage::scheduler' do
29 it 'upgrades mysql python package' do 29 it 'upgrades mysql python package' do
30 expect(chef_run).to upgrade_package 'python-mysqldb' 30 expect(chef_run).to upgrade_package 'python-mysqldb'
31 end 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 end 32 end
40end 33end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index eb82788..cb91497 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -12,7 +12,7 @@ require 'chef/application'
12LOG_LEVEL = :fatal 12LOG_LEVEL = :fatal
13REDHAT_OPTS = { 13REDHAT_OPTS = {
14 platform: 'redhat', 14 platform: 'redhat',
15 version: '7.1', 15 version: '7.3',
16 log_level: LOG_LEVEL, 16 log_level: LOG_LEVEL,
17}.freeze 17}.freeze
18UBUNTU_OPTS = { 18UBUNTU_OPTS = {
@@ -58,6 +58,8 @@ shared_context 'block-storage-stubs' do
58 allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url) 58 allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
59 .with('block-storage') 59 .with('block-storage')
60 .and_return('rabbit://guest:mypass@127.0.0.1:5672') 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 allow(Chef::Application).to receive(:fatal!) 63 allow(Chef::Application).to receive(:fatal!)
62 end 64 end
63end 65end
diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb
index 1830442..7e3e1a4 100644
--- a/spec/volume-redhat_spec.rb
+++ b/spec/volume-redhat_spec.rb
@@ -16,13 +16,6 @@ describe 'openstack-block-storage::volume' do
16 expect(chef_run).to upgrade_package('MySQL-python') 16 expect(chef_run).to upgrade_package('MySQL-python')
17 end 17 end
18 18
19 it '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 it 'upgrades qemu-img-ev package' do 19 it 'upgrades qemu-img-ev package' do
27 expect(chef_run).to upgrade_package('qemu-img-ev') 20 expect(chef_run).to upgrade_package('qemu-img-ev')
28 end 21 end
@@ -41,7 +34,7 @@ describe 'openstack-block-storage::volume' do
41 34
42 context 'ISCSI' do 35 context 'ISCSI' do
43 it 'starts iscsi target on boot' do 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 end 38 end
46 end 39 end
47 end 40 end
diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb
index 5c6b3b2..b5efa33 100644
--- a/spec/volume_spec.rb
+++ b/spec/volume_spec.rb
@@ -22,6 +22,10 @@ describe 'openstack-block-storage::volume' do
22 expect(chef_run).to upgrade_package 'qemu-utils' 22 expect(chef_run).to upgrade_package 'qemu-utils'
23 end 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 it 'starts cinder volume' do 29 it 'starts cinder volume' do
26 expect(chef_run).to start_service 'cinder-volume' 30 expect(chef_run).to start_service 'cinder-volume'
27 end 31 end
@@ -38,13 +42,6 @@ describe 'openstack-block-storage::volume' do
38 expect(chef_run).to upgrade_package 'python-mysqldb' 42 expect(chef_run).to upgrade_package 'python-mysqldb'
39 end 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 it 'upgrades cinder iscsi package' do 45 it 'upgrades cinder iscsi package' do
49 expect(chef_run).to upgrade_package 'tgt' 46 expect(chef_run).to upgrade_package 'tgt'
50 end 47 end
diff --git a/templates/default/cinder-group-active.erb b/templates/default/cinder-group-active.erb
deleted file mode 100644
index 098703f..0000000
--- a/templates/default/cinder-group-active.erb
+++ /dev/null
@@ -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
22start()
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
37RETVAL=0
38
39case "$1" in
40 start)
41 start
42 ;;
43 *)
44 echo "Usage: $0 {start}"
45 RETVAL=1
46esac
47
48exit $RETVAL
diff --git a/templates/default/targets.conf.erb b/templates/default/targets.conf.erb
index ff029e1..27a4139 100644
--- a/templates/default/targets.conf.erb
+++ b/templates/default/targets.conf.erb
@@ -1,9 +1,9 @@
1<%= node["openstack"]["block-storage"]["custom_template_banner"] %> 1<%= node["openstack"]["block-storage"]["custom_template_banner"] %>
2 2
3<% if %w(rhel).include?(node["platform_family"]) %> 3<% if node['platform_family'].include?('rhel') %>
4include <%= node['openstack']['block-storage']['conf']['DEFAULT']['volumes_dir'] %>/* 4include <%= node['openstack']['block-storage']['conf']['DEFAULT']['state_path'] %>/volumes/*
5<% end %> 5<% end %>
6<% if %w(debian).include?(node["platform_family"]) %> 6<% if node['platform_family'].include?('debian') %>
7include /etc/tgt/conf.d/*.conf 7include /etc/tgt/conf.d/*.conf
8<% end %> 8<% end %>
9default-driver iscsi 9default-driver iscsi
diff --git a/templates/default/wsgi-template.conf.erb b/templates/default/wsgi-template.conf.erb
new file mode 100644
index 0000000..564bfc8
--- /dev/null
+++ b/templates/default/wsgi-template.conf.erb
@@ -0,0 +1,42 @@
1<%= node["openstack"]["compute"]["custom_template_banner"] %>
2
3Listen <%= @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
41WSGISocketPrefix <%= @params[:run_dir] -%>
42