Style and lint fixes to support newer ChefDK
- bumps ChefDK release to 0.15.15 in bootstrap Change-Id: I6ce4587caa3ae68ddbd3ef1a521aaf46f4840b2c
This commit is contained in:
parent
14f2c3f0fc
commit
51ac5f8b9f
|
@ -13,7 +13,7 @@ Requirements
|
|||
============
|
||||
|
||||
- Chef 12 or higher
|
||||
- chefdk 0.9.0 for testing (also includes berkshelf for cookbook dependency
|
||||
- chefdk 0.15.15 for testing (also includes berkshelf for cookbook dependency
|
||||
resolution)
|
||||
|
||||
Platform
|
||||
|
|
13
bootstrap.sh
13
bootstrap.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash -x
|
||||
## This script is for installing all the needed packages on centos 7 and trusty to run the chef tests with 'chef exec rake'
|
||||
## This script is for installing all the needed packages on CentOS 7 and Ubuntu Trusty to run the chef tests with 'chef exec rake'
|
||||
|
||||
if [ -f /usr/bin/yum ] ; then
|
||||
# install needed packages
|
||||
|
@ -11,8 +11,8 @@ if [ -f /usr/bin/yum ] ; then
|
|||
sudo pip uninstall requests -y || true
|
||||
|
||||
# install chefdk
|
||||
chefdk=chefdk-0.9.0-1.el7.x86_64.rpm
|
||||
wget -nv -t 3 https://opscode-omnibus-packages.s3.amazonaws.com/el/7/x86_64/$chefdk
|
||||
chefdk=chefdk-0.15.15-1.el7.x86_64.rpm
|
||||
wget -nv -t 3 https://packages.chef.io/stable/el/7/$chefdk
|
||||
sudo yum -y install $chefdk
|
||||
rm $chefdk
|
||||
|
||||
|
@ -26,16 +26,13 @@ elif [ -f /usr/bin/apt-get ]; then
|
|||
sudo apt-get -y install build-essential liblzma-dev zlib1g-dev
|
||||
|
||||
# install chefdk
|
||||
chefdk=chefdk_0.9.0-1_amd64.deb
|
||||
wget -nv -t 3 https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/$chefdk
|
||||
chefdk=chefdk_0.15.15-1_amd64.deb
|
||||
wget -nv -t 3 https://packages.chef.io/stable/ubuntu/12.04/$chefdk
|
||||
sudo dpkg -i $chefdk
|
||||
rm $chefdk
|
||||
|
||||
fi
|
||||
|
||||
## workaround to fix redhat fauxhai permission issue (can be removed with fauxhai > 2.3 in chefdk)
|
||||
sudo chef exec ruby -e "require 'fauxhai'; Fauxhai.mock(platform:'redhat', version:'7.1')"
|
||||
|
||||
# The following will handle cross cookbook patch dependencies via the Depends-On in commit message
|
||||
|
||||
# ZUUL_CHANGES has a ^ separated list of patches, the last being the current patch.
|
||||
|
|
|
@ -64,7 +64,7 @@ module ::Openstack
|
|||
Chef::Log.debug("Running openstack command: #{openstackcmd} with environment: #{env}")
|
||||
result = shell_out(openstackcmd, env: env)
|
||||
Chef::Log.debug("Output for command: #{cmd}:\n#{result.stdout}\n#{result.stderr}")
|
||||
fail "#{result.stderr} (#{result.exitstatus})" if result.exitstatus != 0
|
||||
raise "#{result.stderr} (#{result.exitstatus})" if result.exitstatus != 0
|
||||
result.stdout
|
||||
end
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ module ::Openstack
|
|||
# @param [String] service
|
||||
def merge_config_options(service)
|
||||
conf = deep_dup(node['openstack'][service]['conf'])
|
||||
if node['openstack'][service]['conf_secrets']
|
||||
conf_secrets = deep_dup(node['openstack'][service]['conf_secrets'])
|
||||
else
|
||||
conf_secrets = {}
|
||||
end
|
||||
conf_secrets = if node['openstack'][service]['conf_secrets']
|
||||
deep_dup(node['openstack'][service]['conf_secrets'])
|
||||
else
|
||||
{}
|
||||
end
|
||||
Chef::Mixin::DeepMerge.merge(conf, conf_secrets)
|
||||
end
|
||||
|
||||
|
|
|
@ -49,11 +49,7 @@ if defined?(ChefSpec)
|
|||
# rubocop:disable MethodLength, CyclomaticComplexity
|
||||
def matches_content?
|
||||
def section?(line, section = '.*')
|
||||
if line =~ /^[ \t]*\[#{section}\]/
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
return true if line =~ /^[ \t]*\[#{section}\]/
|
||||
end
|
||||
|
||||
def get_section_content(content, section)
|
||||
|
@ -86,10 +82,6 @@ if defined?(ChefSpec)
|
|||
|
||||
if @expected_content.is_a?(Regexp)
|
||||
|
||||
# MRV Hack to allow windows env to work with rspec
|
||||
# when regex end with $
|
||||
@actual_content = @actual_content.gsub(/\r/, '')
|
||||
|
||||
@actual_content =~ @expected_content
|
||||
elsif RSpec::Matchers.is_a_matcher?(@expected_content)
|
||||
@expected_content.matches?(@actual_content)
|
||||
|
|
|
@ -31,15 +31,16 @@ module ::Openstack
|
|||
def address_for(interface, family = node['openstack']['endpoints']['family'], nodeish = node, drop_vips = true)
|
||||
Chef::Log.debug("address_for(#{interface}, #{family}, #{nodeish})")
|
||||
if interface == 'all'
|
||||
if family == 'inet6'
|
||||
case family
|
||||
when 'inet6'
|
||||
return '::'
|
||||
else
|
||||
when 'inet'
|
||||
return '0.0.0.0'
|
||||
end
|
||||
end
|
||||
fail "Interface #{interface} does not exist" unless nodeish['network']['interfaces'][interface]
|
||||
raise "Interface #{interface} does not exist" unless nodeish['network']['interfaces'][interface]
|
||||
addresses = nodeish['network']['interfaces'][interface]['addresses']
|
||||
fail "Interface #{interface} has no addresses assigned" if addresses.to_a.empty?
|
||||
raise "Interface #{interface} has no addresses assigned" if addresses.to_a.empty?
|
||||
get_address addresses, family, drop_vips
|
||||
end
|
||||
|
||||
|
@ -49,11 +50,11 @@ module ::Openstack
|
|||
# @param [Hash] service_config pointed to the set Hash
|
||||
def bind_address(service_config)
|
||||
iface = service_config['interface']
|
||||
if iface
|
||||
address = address_for(iface)
|
||||
else
|
||||
address = service_config['host']
|
||||
end
|
||||
address = if iface
|
||||
address_for(iface)
|
||||
else
|
||||
service_config['host']
|
||||
end
|
||||
address
|
||||
end
|
||||
|
||||
|
@ -69,6 +70,6 @@ module ::Openstack
|
|||
addresses.each do |addr, data|
|
||||
return addr if data['family'] == family && (data['prefixlen'] != vip_prefixlen || !drop_vips)
|
||||
end
|
||||
fail "No address for family #{family} found"
|
||||
raise "No address for family #{family} found"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,19 +46,17 @@ module ::Openstack
|
|||
# @return [Array] A list of memcached servers in format
|
||||
# '<ip>:<port>'.
|
||||
def memcached_servers(role = 'infra-caching')
|
||||
if !node['openstack']['memcached_servers']
|
||||
if node['openstack']['memcached_servers'].nil?
|
||||
search_for(role).map do |n|
|
||||
listen = n['memcached']['listen']
|
||||
port = n['memcached']['port'] || '11211'
|
||||
|
||||
"#{listen}:#{port}"
|
||||
end.sort
|
||||
elsif node['openstack']['memcached_servers']
|
||||
node['openstack']['memcached_servers']
|
||||
else
|
||||
if node['openstack']['memcached_servers'].length != 0
|
||||
node['openstack']['memcached_servers']
|
||||
else
|
||||
[]
|
||||
end
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ module ::Openstack
|
|||
# intended for joining URI relative path segments. This function merely
|
||||
# helps to accurately join supplied paths.
|
||||
def uri_join_paths(*paths)
|
||||
return nil if paths.length == 0
|
||||
return nil if paths.empty?
|
||||
leadingslash = paths[0][0] == '/' ? '/' : ''
|
||||
trailingslash = paths[-1][-1] == '/' ? '/' : ''
|
||||
paths.map! { |path| path.sub(%r{^\/+}, '').sub(%r{\/+$}, '') }
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
name 'openstack-common'
|
||||
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-common' if respond_to?(:source_url)
|
||||
license 'Apache 2.0'
|
||||
description 'Common OpenStack attributes, libraries and recipes.'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
|
|
|
@ -46,7 +46,7 @@ def db_types
|
|||
@user_prov = ::Chef::Provider::Database::MysqlUser
|
||||
@super_user = 'root'
|
||||
else
|
||||
fail "Unsupported database type #{@db_type}"
|
||||
raise "Unsupported database type #{@db_type}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -30,4 +30,9 @@ template '/etc/openstack/logging.conf' do
|
|||
owner 'root'
|
||||
group 'root'
|
||||
mode 00644
|
||||
variables(
|
||||
loggers: node['openstack']['logging']['loggers'],
|
||||
formatters: node['openstack']['logging']['formatters'],
|
||||
handlers: node['openstack']['logging']['handlers']
|
||||
)
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@ describe 'openstack-common::default' do
|
|||
end
|
||||
|
||||
it 'returns endpoint URI object when uri key not in endpoint hash but host is in hash' do
|
||||
subject.should_receive(:uri_from_hash).with('host' => 'localhost', 'port' => '1234')
|
||||
expect(subject).to receive(:uri_from_hash).with('host' => 'localhost', 'port' => '1234')
|
||||
uri_hash = {
|
||||
'openstack' => {
|
||||
'endpoints' => {
|
||||
|
|
|
@ -19,11 +19,11 @@ describe 'Openstack parse' do
|
|||
end
|
||||
it 'returns proper array of hashes when proper table provided' do
|
||||
table =
|
||||
'+---------+----------------------------------+----------------------------------+
|
||||
| tenant | access | secret |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
| service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 |
|
||||
+---------+----------------------------------+----------------------------------+'
|
||||
'+---------+----------------------------------+----------------------------------+
|
||||
| tenant | access | secret |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
| service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 |
|
||||
+---------+----------------------------------+----------------------------------+'
|
||||
expect(
|
||||
subject.prettytable_to_array(table)
|
||||
).to eq(
|
||||
|
@ -33,11 +33,11 @@ describe 'Openstack parse' do
|
|||
end
|
||||
it 'returns proper array of hashes when proper table provided including whitespace' do
|
||||
table =
|
||||
'+---------+----------------------------------+----------------------------------+
|
||||
| tenant | access | secret |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
| service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
'+---------+----------------------------------+----------------------------------+
|
||||
| tenant | access | secret |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
| service | 91af731b3be244beb8f30fc59b7bc96d | ce811442cfb549c39390a203778a4bf5 |
|
||||
+---------+----------------------------------+----------------------------------+
|
||||
|
||||
|
||||
'
|
||||
|
@ -50,14 +50,14 @@ describe 'Openstack parse' do
|
|||
end
|
||||
it 'returns a flatten hash when provided a Property/Value table' do
|
||||
table =
|
||||
'+-----------+----------------------------------+
|
||||
| Property | Value |
|
||||
+-----------+----------------------------------+
|
||||
| access | 91af731b3be244beb8f30fc59b7bc96d |
|
||||
| secret | ce811442cfb549c39390a203778a4bf5 |
|
||||
| tenant_id | 429271dd1cf54b7ca921a0017524d8ea |
|
||||
| user_id | 1c4fc229560f40689c490c5d0838fd84 |
|
||||
+-----------+----------------------------------+'
|
||||
'+-----------+----------------------------------+
|
||||
| Property | Value |
|
||||
+-----------+----------------------------------+
|
||||
| access | 91af731b3be244beb8f30fc59b7bc96d |
|
||||
| secret | ce811442cfb549c39390a203778a4bf5 |
|
||||
| tenant_id | 429271dd1cf54b7ca921a0017524d8ea |
|
||||
| user_id | 1c4fc229560f40689c490c5d0838fd84 |
|
||||
+-----------+----------------------------------+'
|
||||
expect(
|
||||
subject.prettytable_to_array(table)
|
||||
).to eq(
|
||||
|
@ -68,16 +68,14 @@ describe 'Openstack parse' do
|
|||
end
|
||||
it 'returns a flatten hash when provided a Property/Value table including whitespace' do
|
||||
table =
|
||||
'
|
||||
|
||||
+-----------+----------------------------------+
|
||||
| Property | Value |
|
||||
+-----------+----------------------------------+
|
||||
| access | 91af731b3be244beb8f30fc59b7bc96d |
|
||||
| secret | ce811442cfb549c39390a203778a4bf5 |
|
||||
| tenant_id | 429271dd1cf54b7ca921a0017524d8ea |
|
||||
| user_id | 1c4fc229560f40689c490c5d0838fd84 |
|
||||
+-----------+----------------------------------+'
|
||||
'+-----------+----------------------------------+
|
||||
| Property | Value |
|
||||
+-----------+----------------------------------+
|
||||
| access | 91af731b3be244beb8f30fc59b7bc96d |
|
||||
| secret | ce811442cfb549c39390a203778a4bf5 |
|
||||
| tenant_id | 429271dd1cf54b7ca921a0017524d8ea |
|
||||
| user_id | 1c4fc229560f40689c490c5d0838fd84 |
|
||||
+-----------+----------------------------------+'
|
||||
expect(
|
||||
subject.prettytable_to_array(table)
|
||||
).to eq(
|
||||
|
|
|
@ -34,7 +34,7 @@ describe 'openstack-common::default' do
|
|||
end
|
||||
|
||||
describe '#get_password' do
|
||||
['service', 'db', 'user'].each do |type|
|
||||
%w(service db user).each do |type|
|
||||
it "returns databag value for #{type}" do
|
||||
value = { 'nova' => 'this' }
|
||||
allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret')
|
||||
|
@ -69,7 +69,7 @@ describe 'openstack-common::default' do
|
|||
end
|
||||
|
||||
describe '#get_password' do
|
||||
['service', 'db', 'user'].each do |type|
|
||||
%w(service db user).each do |type|
|
||||
it "returns databag value for #{type}" do
|
||||
value = { 'nova' => 'this' }
|
||||
allow(Chef::DataBagItem).to receive(:load).with("#{type}_passwords", 'nova').and_return(value)
|
||||
|
|
|
@ -9,12 +9,12 @@ UBUNTU_OPTS = {
|
|||
platform: 'ubuntu',
|
||||
version: '14.04',
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
}.freeze
|
||||
REDHAT_OPTS = {
|
||||
platform: 'redhat',
|
||||
version: '7.1',
|
||||
log_level: LOG_LEVEL
|
||||
}
|
||||
}.freeze
|
||||
# We set a default platform for non-platform specific test cases
|
||||
CHEFSPEC_OPTS = UBUNTU_OPTS
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
[loggers]
|
||||
keys=<%= (node["openstack"]["logging"]['loggers'].keys).join(',') %>
|
||||
keys=<%= (@loggers.keys).join(',') %>
|
||||
|
||||
[formatters]
|
||||
keys=<%= node["openstack"]["logging"]['formatters'].keys.join(',') %>
|
||||
keys=<%= @formatters.keys.join(',') %>
|
||||
|
||||
[handlers]
|
||||
keys=<%= node["openstack"]["logging"]['handlers'].keys.join(',') %>
|
||||
keys=<%= @handlers.keys.join(',') %>
|
||||
|
||||
## FORMATTERS ##
|
||||
## LOGGERS ##
|
||||
|
||||
<% node["openstack"]["logging"]['formatters'].each do |section, options| %>
|
||||
[formatter_<%= section %>]
|
||||
<% @loggers.each do |section, options| %>
|
||||
[logger_<%= section %>]
|
||||
<% options.each do |key, value| %>
|
||||
<%= key %>=<%= value %>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
|
||||
## LOGGERS ##
|
||||
## FORMATTERS ##
|
||||
|
||||
<% node["openstack"]["logging"]['loggers'].each do |section, options| %>
|
||||
[logger_<%= section %>]
|
||||
<% @formatters.each do |section, options| %>
|
||||
[formatter_<%= section %>]
|
||||
<% options.each do |key, value| %>
|
||||
<%= key %>=<%= value %>
|
||||
<% end %>
|
||||
|
@ -29,7 +29,7 @@ keys=<%= node["openstack"]["logging"]['handlers'].keys.join(',') %>
|
|||
|
||||
## HANDLERS ##
|
||||
|
||||
<% node["openstack"]["logging"]['handlers'].each do |section, options| %>
|
||||
<% @handlers.each do |section, options| %>
|
||||
[handler_<%= section %>]
|
||||
<% options.each do |key, value| %>
|
||||
<%= key %>=<%= value %>
|
||||
|
|
Loading…
Reference in New Issue