From 7eb5fd61137a5dbc2d5d58cc7e52fda4e30c1ccc Mon Sep 17 00:00:00 2001 From: Samuel Cassiba Date: Sun, 20 Aug 2017 12:17:14 -0400 Subject: [PATCH] Initial image Pike updates - Switched default linter to cookstyle - Freshened image locations - Renamed rake tasks to align with Chef conventions - Normalized template comment Change-Id: Ib99d9b12f036ff52e44a270455f0d2e16561f98a --- .rubocop_todo.yml | 34 +----------------------------- Rakefile | 14 ++++++------ attributes/default.rb | 17 +++++++-------- recipes/api.rb | 2 +- recipes/identity_registration.rb | 4 ++-- spec/api_spec.rb | 14 ++++++------ spec/identity_registration_spec.rb | 2 +- spec/image_upload_spec.rb | 6 +++--- spec/registry_spec.rb | 8 +++---- spec/spec_helper.rb | 4 ++-- 10 files changed, 36 insertions(+), 69 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c71a794..739c2ca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,44 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-08-17 14:16:11 +0200 using RuboCop version 0.47.1. +# on 2017-08-25 09:41:52 -0400 using RuboCop version 0.47.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 16 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 198 - -# Offense count: 1 -# Configuration parameters: CountComments. -Metrics/MethodLength: - Max: 28 - # Offense count: 2 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 6 - -# Offense count: 5 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'recipes/api.rb' - - 'recipes/identity_registration.rb' - - 'recipes/image_upload.rb' - - 'recipes/registry.rb' - - 'recipes/swift_store.rb' - -# Offense count: 5 -Style/Documentation: - Exclude: - - 'spec/**/*' - - 'test/**/*' - - 'recipes/api.rb' - - 'recipes/identity_registration.rb' - - 'recipes/image_upload.rb' - - 'recipes/registry.rb' - - 'recipes/swift_store.rb' diff --git a/Rakefile b/Rakefile index c48cc7e..01bb9f3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,20 +1,20 @@ task default: ["test"] -task :test => [:lint, :style, :unit] +task :test => [:syntax, :lint, :unit] desc "Vendor the cookbooks in the Berksfile" task :berks_prep do sh %{chef exec berks vendor} end -desc "Run FoodCritic (lint) tests" -task :lint do - sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} +desc "Run FoodCritic (syntax) tests" +task :syntax do + sh %{chef exec foodcritic --exclude spec -f any .} end -desc "Run RuboCop (style) tests" -task :style do - sh %{chef exec rubocop} +desc "Run RuboCop (lint) tests" +task :lint do + sh %{chef exec cookstyle} end desc "Run RSpec (unit) tests" diff --git a/attributes/default.rb b/attributes/default.rb index e576516..787f6b9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -23,8 +23,8 @@ # Set to some text value if you want templated config files # to contain a custom banner at the top of the written file default['openstack']['image']['custom_template_banner'] = ' -# This file autogenerated by Chef -# Do not edit, changes will be overwritten +# This file is automatically generated by Chef +# Any changes will be overwritten ' # SSL Options @@ -70,10 +70,9 @@ default['openstack']['image']['cache']['grace_period'] = 3600 # Default Image Locations default['openstack']['image']['upload_images'] = ['cirros'] -default['openstack']['image']['upload_image']['precise'] = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img' -default['openstack']['image']['upload_image']['oneiric'] = 'http://cloud-images.ubuntu.com/oneiric/current/oneiric-server-cloudimg-amd64-disk1.img' -default['openstack']['image']['upload_image']['natty'] = 'http://cloud-images.ubuntu.com/natty/current/natty-server-cloudimg-amd64-disk1.img' -default['openstack']['image']['upload_image']['cirros'] = 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img' +default['openstack']['image']['upload_image']['xenial'] = 'http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img' +default['openstack']['image']['upload_image']['zesty'] = 'http://cloud-images.ubuntu.com/zesty/current/zesty-server-cloudimg-amd64-disk1.img' +default['openstack']['image']['upload_image']['cirros'] = 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img' # more images available at https://github.com/rackerjoe/oz-image-build default['openstack']['image']['upload_image']['centos'] = 'http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2' # To override image type @@ -104,7 +103,7 @@ when 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this 'image_api_service' => 'openstack-glance-api', 'image_registry_service' => 'openstack-glance-registry', 'image_api_process_name' => 'glance-api', - 'package_overrides' => '' + 'package_overrides' => '', } when 'suse' default['openstack']['image']['user'] = 'openstack-glance' @@ -116,7 +115,7 @@ when 'suse' 'image_api_service' => 'openstack-glance-api', 'image_registry_service' => 'openstack-glance-registry', 'image_api_process_name' => 'glance-api', - 'package_overrides' => '' + 'package_overrides' => '', } when 'debian' default['openstack']['image']['user'] = 'glance' @@ -128,7 +127,7 @@ when 'debian' 'image_api_service' => 'glance-api', 'image_registry_service' => 'glance-registry', 'image_registry_process_name' => 'glance-registry', - 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" + 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'", } end diff --git a/recipes/api.rb b/recipes/api.rb index 0b009f1..b1c0919 100644 --- a/recipes/api.rb +++ b/recipes/api.rb @@ -184,6 +184,6 @@ service 'glance-api' do subscribes :restart, [ 'template[/etc/glance/glance-scrubber.conf]', 'template[/etc/glance/glance-cache.conf]', - 'template[/etc/glance/glance-api.conf]' + 'template[/etc/glance/glance-api.conf]', ], :immediately end diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index af3472a..d67a140 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -33,7 +33,7 @@ auth_url = ::URI.decode identity_admin_endpoint.to_s interfaces = { public: { url: public_endpoint('image_api') }, internal: { url: internal_endpoint('image_api') }, - admin: { url: admin_endpoint('image_api') } + admin: { url: admin_endpoint('image_api') }, } admin_user = node['openstack']['identity']['admin_user'] @@ -55,7 +55,7 @@ connection_params = { openstack_username: admin_user, openstack_api_key: admin_pass, openstack_project_name: admin_project, - openstack_domain_name: admin_domain + openstack_domain_name: admin_domain, } # Register Image Service diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 9b9af8d..9db4dd6 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -69,7 +69,7 @@ describe 'openstack-image::api' do /^bind_port = 9292$/, /^registry_host = 127.0.0.1$/, /^registry_port = 9191$/, - /^registry_client_protocol = http$/ + /^registry_client_protocol = http$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('DEFAULT', line) @@ -79,7 +79,7 @@ describe 'openstack-image::api' do it do [ %r{^filesystem_store_datadir = /var/lib/glance/images$}, - /^default_store = file$/ + /^default_store = file$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('glance_store', line) @@ -88,7 +88,7 @@ describe 'openstack-image::api' do it do [ - /^flavor = keystone$/ + /^flavor = keystone$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('paste_deploy', line) @@ -104,7 +104,7 @@ describe 'openstack-image::api' do %r{^signing_dir = /var/cache/glance/api$}, %r{^auth_url = http://127.0.0.1:5000/v3$}, /^password = glance-pass$/, - /^user_domain_name = Default$/ + /^user_domain_name = Default$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('keystone_authtoken', line) @@ -113,7 +113,7 @@ describe 'openstack-image::api' do it do [ - %r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$} + %r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$}, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('database', line) @@ -139,7 +139,7 @@ describe 'openstack-image::api' do it do [ /^registry_port = 9191$/, - /^registry_host = 127.0.0.1$/ + /^registry_host = 127.0.0.1$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('DEFAULT', line) @@ -166,7 +166,7 @@ describe 'openstack-image::api' do it do [ /^registry_port = 9191$/, - /^registry_host = 127.0.0.1$/ + /^registry_host = 127.0.0.1$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('DEFAULT', line) diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 668b7d9..7afc6f5 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -15,7 +15,7 @@ describe 'openstack-image::identity_registration' do openstack_username: 'admin', openstack_api_key: 'admin-pass', openstack_project_name: 'admin', - openstack_domain_name: 'default' + openstack_domain_name: 'default', } service_name = 'glance' service_type = 'image' diff --git a/spec/image_upload_spec.rb b/spec/image_upload_spec.rb index f1bb18b..bdadb59 100644 --- a/spec/image_upload_spec.rb +++ b/spec/image_upload_spec.rb @@ -19,7 +19,7 @@ describe 'openstack-image::image_upload' do it 'uploads the cirros image' do stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep cirros').and_return(false) expect(chef_run).to upload_openstack_image_image('Image setup for cirros').with( - image_url: 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img', + image_url: 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img', image_name: 'cirros', image_type: 'qcow', image_public: true, @@ -39,10 +39,10 @@ describe 'openstack-image::image_upload' do it 'uploads the tar image' do node.set['openstack']['image']['upload_images'] = ['imageName'] - node.set['openstack']['image']['upload_image']['imageName'] = 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz' + node.set['openstack']['image']['upload_image']['imageName'] = 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-uec.tar.gz' stub_command('glance --insecure --os-username admin --os-password admin-pass --os-project-name admin --os-image-url http://127.0.0.1:9292 --os-auth-url http://127.0.0.1:5000/v3 --os-user-domain-name Default --os-project-domain-name Default image-list | grep imageName').and_return(false) expect(chef_run).to upload_openstack_image_image('Image setup for imageName').with( - image_url: 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-uec.tar.gz', + image_url: 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-uec.tar.gz', image_name: 'imageName', image_type: 'unknown', image_public: true diff --git a/spec/registry_spec.rb b/spec/registry_spec.rb index f712dd0..b2350b4 100644 --- a/spec/registry_spec.rb +++ b/spec/registry_spec.rb @@ -70,7 +70,7 @@ describe 'openstack-image::registry' do %r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$}, %r{^log_file = /var/log/glance/registry.log$}, /^bind_port = 9191$/, - /^bind_host = 127.0.0.1$/ + /^bind_host = 127.0.0.1$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('DEFAULT', line) @@ -79,7 +79,7 @@ describe 'openstack-image::registry' do it do [ - /^flavor = keystone$/ + /^flavor = keystone$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('paste_deploy', line) @@ -95,7 +95,7 @@ describe 'openstack-image::registry' do %r{^signing_dir = /var/cache/glance/registry}, %r{^auth_url = http://127.0.0.1:5000/v3}, /^user_domain_name = Default$/, - /^password = glance-pass$/ + /^password = glance-pass$/, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('keystone_authtoken', line) @@ -104,7 +104,7 @@ describe 'openstack-image::registry' do it do [ - %r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$} + %r{^connection = mysql\+pymysql://glance:db-pass@127\.0\.0\.1:3306/glance\?charset=utf8$}, ].each do |line| expect(chef_run).to render_config_file(file.name) .with_section_content('database', line) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6f4df49..1fc952c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,12 +10,12 @@ LOG_LEVEL = :fatal REDHAT_OPTS = { platform: 'redhat', version: '7.1', - log_level: LOG_LEVEL + log_level: LOG_LEVEL, }.freeze UBUNTU_OPTS = { platform: 'ubuntu', version: '16.04', - log_level: LOG_LEVEL + log_level: LOG_LEVEL, }.freeze # Helper methods