Initial Rubocop cleanup.

Change-Id: I6f7c659e4f9ea9fa959a9917e4cf9d5e7acb16af
Addresses: blueprint rubocop-for-orchestration
This commit is contained in:
Matt Ray 2014-01-15 16:30:33 -06:00
parent 0b81a7b037
commit 068ed603ed
9 changed files with 203 additions and 127 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.bundle/
.cookbooks/

16
.rubocop.yml Normal file
View File

@ -0,0 +1,16 @@
AllCops:
Includes:
- metadata.rb
- Gemfile
- attributes/**
Excludes:
- recipes/**
- spec/**
# ignore long lines
LineLength:
Enabled: false
# Allow small arrays before forcing %w or %W
WordArray:
MinSize: 3

View File

@ -14,13 +14,13 @@
"ref": "3ca576b8e6dfca3b39ab4ccd7327a40c78379985"
},
"apt": {
"locked_version": "2.3.0"
"locked_version": "2.3.4"
},
"database": {
"locked_version": "1.5.2"
"locked_version": "1.6.0"
},
"mysql": {
"locked_version": "4.0.6"
"locked_version": "4.0.14"
},
"openssl": {
"locked_version": "1.1.0"

17
Gemfile
View File

@ -1,9 +1,10 @@
source "https://rubygems.org"
# encoding: UTF-8
source 'https://rubygems.org'
gem "chef", "~> 11.4.4"
gem "json", "<= 1.7.7" # chef 11 dependency
gem "berkshelf", "~> 2.0.10"
gem "chefspec", "~> 3.0.2"
gem "foodcritic", "~> 3.0.3"
gem "strainer"
gem "rubocop"
gem 'chef', '~> 11.8'
gem 'json', '<= 1.7.7' # chef 11 dependency
gem 'berkshelf', '~> 2.0.10'
gem 'chefspec', '~> 3.1.4'
gem 'foodcritic', '~> 3.0.3'
gem 'strainer'
gem 'rubocop', '>= 0.16.0'

View File

@ -37,28 +37,41 @@ GEM
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.4.4)
erubis
highline (>= 1.6.9)
chef (11.8.2)
chef-zero (~> 1.6, >= 1.6.2)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
highline (~> 1.6, >= 1.6.9)
json (>= 1.4.4, <= 1.7.7)
mixlib-authentication (>= 1.3.0)
mixlib-cli (~> 1.3.0)
mixlib-config (>= 1.1.2)
mixlib-log (>= 1.3.0)
mixlib-shellout
mime-types (~> 1.16)
mixlib-authentication (~> 1.3)
mixlib-cli (~> 1.3)
mixlib-config (~> 2.0)
mixlib-log (~> 1.3)
mixlib-shellout (~> 1.2)
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1.0)
ohai (>= 0.6.0)
ohai (~> 6.0)
pry (~> 0.9)
puma (~> 1.6)
rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1)
chefspec (3.0.2)
chef-zero (1.7.2)
hashie (~> 2.0)
json
mixlib-log (~> 1.3)
moneta (< 0.7.0)
rack
chefspec (3.1.4)
chef (~> 11.0)
fauxhai (~> 2.0)
i18n (>= 0.6.9, < 1.0.0)
rspec (~> 2.14)
chozo (0.6.1)
activesupport (>= 3.2.0)
hashie (>= 2.0.2)
multi_json (>= 1.3.0)
coderay (1.1.0)
diff-lcs (1.2.5)
erubis (2.7.0)
faraday (0.8.8)
@ -92,14 +105,16 @@ GEM
logging (1.8.1)
little-plugger (>= 1.1.3)
multi_json (>= 1.3.6)
mime-types (2.0)
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.3.0)
mixlib-cli (1.4.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.3.0)
moneta (0.6.0)
multi_json (1.8.2)
multipart-post (1.2.0)
net-http-persistent (2.9)
@ -125,6 +140,12 @@ GEM
slop (~> 3.4, >= 3.4.5)
polyglot (0.3.3)
powerpack (0.0.9)
pry (0.9.12.4)
coderay (~> 1.0)
method_source (~> 0.8)
slop (~> 3.4)
puma (1.6.3)
rack (~> 1.2)
rack (1.5.2)
rainbow (1.99.0)
rake (10.1.1)
@ -205,9 +226,9 @@ PLATFORMS
DEPENDENCIES
berkshelf (~> 2.0.10)
chef (~> 11.4.4)
chefspec (~> 3.0.2)
chef (~> 11.8)
chefspec (~> 3.1.4)
foodcritic (~> 3.0.3)
json (<= 1.7.7)
rubocop
rubocop (>= 0.16.0)
strainer

View File

@ -8,7 +8,7 @@ http://heat.openstack.org/
Requirements
============
Chef 0.10.0 or higher required (for Chef environment use).
Chef 11 or higher required (for Chef environment use).
Cookbooks
---------
@ -99,23 +99,16 @@ TODO: move rabbit parameters under openstack["orchestration"]["mq"]
Testing
=====
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
Tests are defined in Strainerfile.
To run tests:
$ bundle install # install gem dependencies
$ bundle exec berks install # install cookbook dependencies
$ bundle exec strainer test # run tests
Please refer to the [TESTING.md](TESTING.md) for instructions for testing the cookbook.
License and Author
==================
| | |
|:---------------------|:---------------------------------------------------|
| **Author** | Zhao Fang Han (<hanzhf@cn.ibm.com>) |
| | | |
| **Author** | Zhao Fang Han (<hanzhf@cn.ibm.com>) |
| | |
| **Copyright** | Copyright (c) 2013, IBM Corp. |
Licensed under the Apache License, Version 2.0 (the "License");

42
TESTING.md Normal file
View File

@ -0,0 +1,42 @@
# Testing the Cookbook #
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
Tests are defined in [Strainerfile](Strainerfile), which in turn calls rubocop, knife, foodcritic and chefspec.
To run all of the tests with Strainer:
$ bundle exec strainer test -s Strainerfile
Or you may run the tests individually:
$ bundle install --path=.bundle # install gem dependencies
$ bundle exec berks install --path=.cookbooks # install cookbook dependencies
$ bundle exec strainer test -s Strainerfile # run tests
## Rubocop ##
[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.
### Attribute Rules ###
Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
[Gemfile and metadata.rb](.rubocop.yml)
[attributes/*.rb](attributes/.rubocop.yml)
[recipes/.rubocop.yml](recipes/.rubocop.yml)
[spec/.rubocop.yml](spec/.rubocop.yml)
## Knife ##
[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors.
## Foodcritic ##
[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules:
[FC003](http://acrmp.github.io/foodcritic/#FC003) these cookbooks are not intended for Chef Solo.
## Chefspec
[ChefSpec](http://code.sethvargo.com/chefspec/) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.

View File

@ -1,3 +1,4 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-orchestration
# Attributes:: default
@ -18,121 +19,120 @@
# 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"]["orchestration"]["custom_template_banner"] = "
default['openstack']['orchestration']['custom_template_banner'] = '
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
"
'
default["openstack"]["orchestration"]["verbose"] = "False"
default["openstack"]["orchestration"]["debug"] = "False"
default['openstack']['orchestration']['verbose'] = 'False'
default['openstack']['orchestration']['debug'] = 'False'
# This is the name of the Chef role that will install the Keystone Service API
default["openstack"]["orchestration"]["identity_service_chef_role"] = "os-identity"
default['openstack']['orchestration']['identity_service_chef_role'] = 'os-identity'
# Gets set in the Heat Endpoint when registering with Keystone
default["openstack"]["orchestration"]["region"] = "RegionOne"
default['openstack']['orchestration']['region'] = 'RegionOne'
# The name of the Chef role that knows about the message queue server
# that Heat uses
default["openstack"]["orchestration"]["rabbit_server_chef_role"] = "os-ops-messaging"
default['openstack']['orchestration']['rabbit_server_chef_role'] = 'os-ops-messaging'
default["openstack"]["orchestration"]["db"]["username"] = "heat"
default['openstack']['orchestration']['db']['username'] = 'heat'
# This user's password is stored in an encrypted databag
# and accessed with openstack-common cookbook library's
# user_password routine. You are expected to create
# the user, pass, vhost in a wrapper rabbitmq cookbook.
default["openstack"]["orchestration"]["rabbit"]["ha"] = false
default["openstack"]["orchestration"]["rabbit"]["username"] = "guest"
default["openstack"]["orchestration"]["rabbit"]["vhost"] = "/"
default["openstack"]["orchestration"]["rabbit"]["port"] = 5672
default["openstack"]["orchestration"]["rabbit"]["host"] = "127.0.0.1"
default['openstack']['orchestration']['rabbit']['ha'] = false
default['openstack']['orchestration']['rabbit']['username'] = 'guest'
default['openstack']['orchestration']['rabbit']['vhost'] = '/'
default['openstack']['orchestration']['rabbit']['port'] = 5672
default['openstack']['orchestration']['rabbit']['host'] = '127.0.0.1'
# MQ options
default["openstack"]["orchestration"]["mq"]["service_type"] = node["openstack"]["mq"]["service_type"]
default["openstack"]["orchestration"]["mq"]["qpid"]["host"] = "127.0.0.1"
default["openstack"]["orchestration"]["mq"]["qpid"]["port"] = "5672"
default["openstack"]["orchestration"]["mq"]["qpid"]["qpid_hosts"] = ['127.0.0.1:5672']
default['openstack']['orchestration']['mq']['service_type'] = node['openstack']['mq']['service_type']
default['openstack']['orchestration']['mq']['qpid']['host'] = '127.0.0.1'
default['openstack']['orchestration']['mq']['qpid']['port'] = '5672'
default['openstack']['orchestration']['mq']['qpid']['qpid_hosts'] = ['127.0.0.1:5672']
default["openstack"]["orchestration"]["mq"]["qpid"]["username"] = ""
default["openstack"]["orchestration"]["mq"]["qpid"]["password"] = ""
default["openstack"]["orchestration"]["mq"]["qpid"]["sasl_mechanisms"] = ""
default["openstack"]["orchestration"]["mq"]["qpid"]["reconnect_timeout"] = 0
default["openstack"]["orchestration"]["mq"]["qpid"]["reconnect_limit"] = 0
default["openstack"]["orchestration"]["mq"]["qpid"]["reconnect_interval_min"] = 0
default["openstack"]["orchestration"]["mq"]["qpid"]["reconnect_interval_max"] = 0
default["openstack"]["orchestration"]["mq"]["qpid"]["reconnect_interval"] = 0
default["openstack"]["orchestration"]["mq"]["qpid"]["heartbeat"] = 60
default["openstack"]["orchestration"]["mq"]["qpid"]["protocol"] = "tcp"
default["openstack"]["orchestration"]["mq"]["qpid"]["tcp_nodelay"] = true
default['openstack']['orchestration']['mq']['qpid']['username'] = ''
default['openstack']['orchestration']['mq']['qpid']['password'] = ''
default['openstack']['orchestration']['mq']['qpid']['sasl_mechanisms'] = ''
default['openstack']['orchestration']['mq']['qpid']['reconnect_timeout'] = 0
default['openstack']['orchestration']['mq']['qpid']['reconnect_limit'] = 0
default['openstack']['orchestration']['mq']['qpid']['reconnect_interval_min'] = 0
default['openstack']['orchestration']['mq']['qpid']['reconnect_interval_max'] = 0
default['openstack']['orchestration']['mq']['qpid']['reconnect_interval'] = 0
default['openstack']['orchestration']['mq']['qpid']['heartbeat'] = 60
default['openstack']['orchestration']['mq']['qpid']['protocol'] = 'tcp'
default['openstack']['orchestration']['mq']['qpid']['tcp_nodelay'] = true
default["openstack"]["orchestration"]["service_tenant_name"] = "service"
default["openstack"]["orchestration"]["service_user"] = "heat"
default["openstack"]["orchestration"]["service_role"] = "admin"
default['openstack']['orchestration']['service_tenant_name'] = 'service'
default['openstack']['orchestration']['service_user'] = 'heat'
default['openstack']['orchestration']['service_role'] = 'admin'
default["openstack"]["orchestration"]["api"]["auth"]["version"] = "v2.0"
default['openstack']['orchestration']['api']['auth']['version'] = 'v2.0'
# If set, heat API service will bind to the address on this interface,
# otherwise it will bind to the API endpoint's host.
default["openstack"]["orchestration"]["api"]["bind_interface"] = nil
default['openstack']['orchestration']['api']['bind_interface'] = nil
# If set, heat api-cfn service will bind to the address on this interface,
# otherwise it will bind to the API endpoint's host.
default["openstack"]["orchestration"]["api-cfn"]["bind_interface"] = nil
default['openstack']['orchestration']['api-cfn']['bind_interface'] = nil
# If set, heat api-cloudwatch service will bind to the address on this interface,
# otherwise it will bind to the API endpoint's host.
default["openstack"]["orchestration"]["api-cloudwatch"]["bind_interface"] = nil
default['openstack']['orchestration']['api-cloudwatch']['bind_interface'] = nil
# Keystone PKI signing directory. Only written to the filter:authtoken section
# of the api-paste.ini when node["openstack"]["auth"]["strategy"] == "pki"
default["openstack"]["orchestration"]["api"]["auth"]["cache_dir"] = "/var/cache/heat"
# of the api-paste.ini when node['openstack']['auth']['strategy'] == 'pki'
default['openstack']['orchestration']['api']['auth']['cache_dir'] = '/var/cache/heat'
# logging attribute
default["openstack"]["orchestration"]["syslog"]["use"] = false
default["openstack"]["orchestration"]["syslog"]["facility"] = "LOG_LOCAL2"
default["openstack"]["orchestration"]["syslog"]["config_facility"] = "local2"
default['openstack']['orchestration']['syslog']['use'] = false
default['openstack']['orchestration']['syslog']['facility'] = 'LOG_LOCAL2'
default['openstack']['orchestration']['syslog']['config_facility'] = 'local2'
# Common rpc definitions
default["openstack"]["orchestration"]["rpc_thread_pool_size"] = 64
default["openstack"]["orchestration"]["rpc_conn_pool_size"] = 30
default["openstack"]["orchestration"]["rpc_response_timeout"] = 60
default['openstack']['orchestration']['rpc_thread_pool_size'] = 64
default['openstack']['orchestration']['rpc_conn_pool_size'] = 30
default['openstack']['orchestration']['rpc_response_timeout'] = 60
# platform-specific settings
case platform
when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won't fix this
default["openstack"]["orchestration"]["user"] = "heat"
default["openstack"]["orchestration"]["group"] = "heat"
default["openstack"]["orchestration"]["platform"] = {
"mysql_python_packages" => [ "MySQL-python" ],
"postgresql_python_packages" => ["python-psycopg2"],
"heat_common_packages" => [ "openstack-heat" ],
"heat_api_packages" => ["python-heatclient"],
"heat_api_service" => "openstack-heat-api",
"heat_api_cfn_packages" => ["python-heatclient"],
"heat_api_cfn_service" => "openstack-heat-api-cfn",
"heat_api_cloudwatch_packages" => ["python-heatclient"],
"heat_api_cloudwatch_service" => "openstack-heat-api-cloudwatch",
"heat_engine_packages" => [],
"heat_engine_service" => "openstack-heat-engine",
"heat_api_process_name" => "heat-api",
"package_overrides" => ""
when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this
default['openstack']['orchestration']['user'] = 'heat'
default['openstack']['orchestration']['group'] = 'heat'
default['openstack']['orchestration']['platform'] = {
'mysql_python_packages' => ['MySQL-python'],
'postgresql_python_packages' => ['python-psycopg2'],
'heat_common_packages' => ['openstack-heat'],
'heat_api_packages' => ['python-heatclient'],
'heat_api_service' => 'openstack-heat-api',
'heat_api_cfn_packages' => ['python-heatclient'],
'heat_api_cfn_service' => 'openstack-heat-api-cfn',
'heat_api_cloudwatch_packages' => ['python-heatclient'],
'heat_api_cloudwatch_service' => 'openstack-heat-api-cloudwatch',
'heat_engine_packages' => [],
'heat_engine_service' => 'openstack-heat-engine',
'heat_api_process_name' => 'heat-api',
'package_overrides' => ''
}
when "ubuntu"
default["openstack"]["orchestration"]["user"] = "heat"
default["openstack"]["orchestration"]["group"] = "heat"
default["openstack"]["orchestration"]["platform"] = {
"mysql_python_packages" => [ "python-mysqldb" ],
"postgresql_python_packages" => ["python-psycopg2"],
"heat_common_packages" => ["heat-common"],
"heat_api_packages" => ["heat-api", "python-heatclient"],
"heat_api_service" => "heat-api",
"heat_api_cfn_packages" => ["heat-api-cfn","python-heatclient"],
"heat_api_cfn_service" => "heat-api-cfn",
"heat_api_cloudwatch_packages" => ["heat-api-cloudwatch","python-heatclient"],
"heat_api_cloudwatch_service" => "heat-api-cloudwatch",
"heat_engine_packages" => ["heat-engine"],
"heat_engine_service" => "heat-engine",
"package_overrides" => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
when 'ubuntu'
default['openstack']['orchestration']['user'] = 'heat'
default['openstack']['orchestration']['group'] = 'heat'
default['openstack']['orchestration']['platform'] = {
'mysql_python_packages' => ['python-mysqldb'],
'postgresql_python_packages' => ['python-psycopg2'],
'heat_common_packages' => ['heat-common'],
'heat_api_packages' => ['heat-api', 'python-heatclient'],
'heat_api_service' => 'heat-api',
'heat_api_cfn_packages' => ['heat-api-cfn', 'python-heatclient'],
'heat_api_cfn_service' => 'heat-api-cfn',
'heat_api_cloudwatch_packages' => ['heat-api-cloudwatch', 'python-heatclient'],
'heat_api_cloudwatch_service' => 'heat-api-cloudwatch',
'heat_engine_packages' => ['heat-engine'],
'heat_engine_service' => 'heat-engine',
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
}
end

View File

@ -1,19 +1,20 @@
name "openstack-orchestration"
maintainer "IBM, Inc."
license "Apache 2.0"
description "Installs and configures the Heat Service"
# encoding: UTF-8
name 'openstack-orchestration'
maintainer 'IBM, Inc.'
license 'Apache 2.0'
description 'Installs and configures the Heat Service'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "8.0.0"
recipe "openstack-orchestration::common", "Installs packages and set up configuraitions for a Heat Server"
recipe "openstack-orchestration::api", "Start Heat Api service and set up configuraions for this service"
recipe "openstack-orchestration::api-cfn", "Start Heat Api CloudFormation service and set up configuraions for this service"
recipe "openstack-orchestration::api-cloudwatch", "Start Heat Api CloudWatch service and set up configuraions for this service"
recipe "openstack-orchestration::engine", "Setup Heat database and start Heat Engine service"
recipe "openstack-orchestration::identity_registration", "Registers Heat service, user and endpoints with Keystone"
version '8.0.0'
recipe 'openstack-orchestration::common', 'Installs packages and configures a Heat Server'
recipe 'openstack-orchestration::api', 'Start and configure the Heat API service'
recipe 'openstack-orchestration::api-cfn', 'Start and configure the Heat API CloudFormation service'
recipe 'openstack-orchestration::api-cloudwatch', 'Start and configure the Heat API CloudWatch service'
recipe 'openstack-orchestration::engine', 'Sets up Heat database and starts Heat Engine service'
recipe 'openstack-orchestration::identity_registration', 'Registers Heat service, user and endpoints with Keystone'
%w{ ubuntu fedora redhat centos }.each do |os|
supports os
end
depends "openstack-common", "~> 8.0"
depends "openstack-identity", "~> 8.0"
depends 'openstack-common', '~> 8.0'
depends 'openstack-identity', '~> 8.0'