From 859fc5df200f12ef92e779b8138d2899b306f974 Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Sun, 26 Nov 2017 23:34:59 -0800 Subject: [PATCH] compute refactor for Pike and Chef 13 - implemented foodcritic and cookstyle corrections - deprecated node.foo.bar method access for node['foo']['bar'] bracket access - parameterize run directory for apache2 Implements blueprint modern-chef Change-Id: I6cf4cd67a96c7d353c4871db02be42ebdc9c1528 --- Berksfile | 24 ++-- LICENSE | 176 +++++++++++++++++++++++ Rakefile | 31 ++-- attributes/default.rb | 2 +- files/default/nova-compute.conf | 4 +- metadata.rb | 34 +++-- recipes/nova-common.rb | 8 +- recipes/placement_api.rb | 1 + spec/compute_spec.rb | 14 -- spec/spec_helper.rb | 2 +- templates/default/wsgi-template.conf.erb | 3 +- 11 files changed, 239 insertions(+), 60 deletions(-) create mode 100644 LICENSE diff --git a/Berksfile b/Berksfile index 48f8cb7b..6a9142bb 100644 --- a/Berksfile +++ b/Berksfile @@ -1,14 +1,14 @@ -source "https://supermarket.chef.io" +source 'https://supermarket.chef.io' + +%w(common identity image network).each do |cookbook| + if Dir.exist?("../cookbook-openstack-#{cookbook}") + cookbook "openstack-#{cookbook}", path: "../cookbook-openstack-#{cookbook}" + else + cookbook "openstack-#{cookbook}", github: "openstack/cookbook-openstack-#{cookbook}" + end +end + +cookbook 'openstackclient', + github: 'cloudbau/cookbook-openstackclient' metadata - -cookbook "openstack-network", - github: "openstack/cookbook-openstack-network" -cookbook "openstack-image", - github: "openstack/cookbook-openstack-image" -cookbook "openstack-identity", - github: "openstack/cookbook-openstack-identity" -cookbook "openstack-common", - github: "openstack/cookbook-openstack-common" -cookbook "openstackclient", - github: "cloudbau/cookbook-openstackclient" diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..68c771a0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,176 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + diff --git a/Rakefile b/Rakefile index 932f2ad3..f9104e8e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,40 +1,39 @@ -task default: ["test"] +task default: ['test'] -task :test => [:syntax, :lint, :unit] +task test: [:syntax, :lint, :unit] -desc "Vendor the cookbooks in the Berksfile" +desc 'Vendor the cookbooks in the Berksfile' task :berks_prep do - sh %{chef exec berks vendor} + sh %(chef exec berks vendor) end -desc "Run FoodCritic (syntax) tests" +desc 'Run FoodCritic (syntax) tests' task :syntax do - sh %{chef exec foodcritic --exclude spec -f any .} + sh %(chef exec foodcritic --exclude spec -f any .) end -desc "Run CookStyle (lint) tests" +desc 'Run CookStyle (lint) tests' task :lint do - sh %{chef exec cookstyle} + sh %(chef exec cookstyle) end -desc "Run RSpec (unit) tests" -task :unit => :berks_prep do - sh %{chef exec rspec --format documentation} +desc 'Run RSpec (unit) tests' +task unit: :berks_prep do + sh %(chef exec rspec --format documentation) end -desc "Remove the berks-cookbooks directory and the Berksfile.lock" +desc 'Remove the berks-cookbooks directory and the Berksfile.lock' task :clean do rm_rf [ 'berks-cookbooks', - 'Berksfile.lock' + 'Berksfile.lock', ] end -desc "All-in-One Neutron build Infra using Common task" +desc 'All-in-One Neutron build Infra using Common task' task :integration do # Use the common integration task sh %(wget -nv -t 3 -O Rakefile-Common https://raw.githubusercontent.com/openstack/cookbook-openstack-common/master/Rakefile) load './Rakefile-Common' - Rake::Task["common_integration"].invoke + Rake::Task['common_integration'].invoke end - diff --git a/attributes/default.rb b/attributes/default.rb index f2c11b0f..73ee8658 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -205,7 +205,7 @@ when 'debian' 'common_packages' => ['nova-common'], 'iscsi_helper' => 'tgtadm', 'volume_packages' => ['sysfsutils', 'sg3-utils', 'multipath-tools'], - 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", + 'package_overrides' => '', } end diff --git a/files/default/nova-compute.conf b/files/default/nova-compute.conf index 81c5705d..44786c6d 100644 --- a/files/default/nova-compute.conf +++ b/files/default/nova-compute.conf @@ -1,5 +1,5 @@ -# This file autogenerated by Chef -# Do not edit, changes will be overwritten +# This file is automatically generated by Chef. +# Do not edit. Changes will be overwritten. # # On ubuntu systems, this file is populated (by the nova-compute package) with: # diff --git a/metadata.rb b/metadata.rb index 306100f9..48ecda53 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,19 +1,35 @@ -name 'openstack-compute' -maintainer 'openstack-chef' +name 'openstack-compute' +maintainer 'openstack-chef' 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-compute' if respond_to?(:source_url) -license 'Apache 2.0' -description 'The OpenStack Compute service Nova.' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '16.0.0' +issues_url 'https://launchpad.net/openstack-chef' if respond_to?(:issues_url) +source_url 'https://github.com/openstack/cookbook-openstack-compute' if respond_to?(:source_url) +license 'Apache-2.0' +description 'The OpenStack Compute service Nova.' +version '16.0.0' + chef_version '>= 12.5' if respond_to?(:chef_version) +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) + +recipe 'openstack-compute::api-metadata', 'Installs/Configures nova api metadata service' +recipe 'openstack-compute::api-os-compute', 'Installs/Configures nova api service' +recipe 'openstack-compute::compute', 'Installs/Configures nova compute service' +recipe 'openstack-compute::conductor', 'Installs/configures nova conductor service' +recipe 'openstack-compute::identity_registration', 'Identity registration' +recipe 'openstack-compute::libvirt', 'Installs/Configures libvirt' +recipe 'openstack-compute::libvirt_rbd', 'Installs/Configures libvirt_rbd' +recipe 'openstack-compute::nova-common', 'Common recipe for nova' +recipe 'openstack-compute::_nova_cell', 'Helper recipe for configuring nova cells' +recipe 'openstack-compute::nova-setup.rb', 'Nova setup recipe' +recipe 'openstack-compute::placement_api', 'Installs/Configures nova placement api' +recipe 'openstack-compute::scheduler', 'Installs/Configures nova scheduler service' +recipe 'openstack-compute::serialproxy', 'Installs/Configures nova serial proxy' +recipe 'openstack-compute::vncproxy', 'Installs/Configures nova vnc proxy' %w(ubuntu redhat centos).each do |os| supports os end -depends 'ceph', '>= 0.9.2' +depends 'ceph' depends 'openstack-common', '>= 16.0.0' depends 'openstack-identity', '>= 16.0.0' depends 'openstack-image', '>= 16.0.0' diff --git a/recipes/nova-common.rb b/recipes/nova-common.rb index b1c6c1a6..87b6fdc6 100644 --- a/recipes/nova-common.rb +++ b/recipes/nova-common.rb @@ -165,19 +165,19 @@ node.default['openstack']['compute']['conf'].tap do |conf| if node['openstack']['compute']['conf']['DEFAULT']['enabled_apis'].include?('osapi_compute') conf['DEFAULT']['osapi_compute_listen'] = compute_api_bind_address - conf['DEFAULT']['osapi_compute_listen_port'] = compute_api_bind.port + conf['DEFAULT']['osapi_compute_listen_port'] = compute_api_bind['port'] end # if node['openstack']['mq']['compute']['rabbit']['ha'] # conf['DEFAULT']['rabbit_hosts'] = rabbit_hosts # end conf['DEFAULT']['metadata_listen'] = compute_metadata_api_bind_address - conf['DEFAULT']['metadata_listen_port'] = compute_metadata_api_bind.port + conf['DEFAULT']['metadata_listen_port'] = compute_metadata_api_bind['port'] conf['vnc']['novncproxy_base_url'] = novnc_endpoint.to_s conf['vnc']['xvpvncproxy_base_url'] = xvpvnc_endpoint.to_s conf['vnc']['xvpvncproxy_host'] = xvpvnc_bind_address - conf['vnc']['xvpvncproxy_port'] = xvpvnc_bind.port + conf['vnc']['xvpvncproxy_port'] = xvpvnc_bind['port'] conf['vnc']['novncproxy_host'] = novnc_bind_address - conf['vnc']['novncproxy_port'] = novnc_bind.port + conf['vnc']['novncproxy_port'] = novnc_bind['port'] conf['vnc']['vncserver_listen'] = vnc_bind_address conf['vnc']['vncserver_proxyclient_address'] = vnc_proxy_bind_address unless memcache_servers.empty? diff --git a/recipes/placement_api.rb b/recipes/placement_api.rb index b2c94f12..787e4e83 100644 --- a/recipes/placement_api.rb +++ b/recipes/placement_api.rb @@ -58,6 +58,7 @@ web_app 'placement-api' do server_port bind_service['port'] server_entry '/usr/bin/nova-placement-api' log_dir node['apache']['log_dir'] + run_dir node['apache']['run_dir'] user node['openstack']['compute']['user'] group node['openstack']['compute']['group'] use_ssl node['openstack']['placement']['ssl']['enabled'] diff --git a/spec/compute_spec.rb b/spec/compute_spec.rb index 5de07660..521248a9 100644 --- a/spec/compute_spec.rb +++ b/spec/compute_spec.rb @@ -39,13 +39,6 @@ describe 'openstack-compute::compute' do expect(chef_run).not_to upgrade_package 'nova-compute-qemu' end - it 'honors the package options platform overrides for kvm' do - node.set['openstack']['compute']['conf']['libvirt']['virt_type'] = 'kvm' - node.set['openstack']['compute']['platform']['package_overrides'] = '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes' - - expect(chef_run).to upgrade_package('nova-compute-kvm').with(options: '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes') - end - it 'upgrades qemu when virt_type is qemu' do node.set['openstack']['compute']['conf']['libvirt']['virt_type'] = 'qemu' @@ -53,13 +46,6 @@ describe 'openstack-compute::compute' do expect(chef_run).not_to upgrade_package 'nova-compute-kvm' end - it 'honors the package options platform overrides for qemu' do - node.set['openstack']['compute']['conf']['libvirt']['virt_type'] = 'qemu' - node.set['openstack']['compute']['platform']['package_overrides'] = '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes' - - expect(chef_run).to upgrade_package('nova-compute-qemu').with(options: '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes') - end - %w(qemu kvm).each do |virt_type| it "honors the package name platform overrides for #{virt_type}" do node.set['openstack']['compute']['conf']['libvirt']['virt_type'] = virt_type diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eac98607..339cec34 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ LOG_LEVEL = :fatal REDHAT_OPTS = { platform: 'redhat', - version: '7.1', + version: '7.3', log_level: LOG_LEVEL, }.freeze UBUNTU_OPTS = { diff --git a/templates/default/wsgi-template.conf.erb b/templates/default/wsgi-template.conf.erb index a05f5ada..564bfc83 100644 --- a/templates/default/wsgi-template.conf.erb +++ b/templates/default/wsgi-template.conf.erb @@ -38,4 +38,5 @@ Listen <%= @params[:server_host] %>:<%= @params[:server_port] %> <% end -%> -WSGISocketPrefix /var/run/apache2 +WSGISocketPrefix <%= @params[:run_dir] -%> +