diff --git a/attributes/database.rb b/attributes/database.rb index 119c00a5..226c1fb5 100644 --- a/attributes/database.rb +++ b/attributes/database.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # Attributes:: database diff --git a/attributes/default.rb b/attributes/default.rb index 9fa2ed1a..2fefd769 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # Attributes:: default diff --git a/attributes/messaging.rb b/attributes/messaging.rb index b0467148..c0af61a7 100644 --- a/attributes/messaging.rb +++ b/attributes/messaging.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # Attributes:: messaging diff --git a/libraries/cli.rb b/libraries/cli.rb index 4e5d3fc5..b7ccaa39 100644 --- a/libraries/cli.rb +++ b/libraries/cli.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: cli diff --git a/libraries/config_helpers.rb b/libraries/config_helpers.rb index 5acc335d..b3d933e6 100644 --- a/libraries/config_helpers.rb +++ b/libraries/config_helpers.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: config_helpers diff --git a/libraries/endpoints.rb b/libraries/endpoints.rb index 03fd5a3f..6c1bdba9 100644 --- a/libraries/endpoints.rb +++ b/libraries/endpoints.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: endpoints diff --git a/libraries/matchers.rb b/libraries/matchers.rb index d8b1dfb4..95733c07 100644 --- a/libraries/matchers.rb +++ b/libraries/matchers.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - if defined?(ChefSpec) # diff --git a/libraries/network.rb b/libraries/network.rb index 51ddc62e..425b5e6a 100644 --- a/libraries/network.rb +++ b/libraries/network.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: network @@ -50,12 +48,11 @@ module ::Openstack # @param [Hash] service_config pointed to the set Hash def bind_address(service_config) iface = service_config['interface'] - address = if iface - address_for(iface) - else - service_config['host'] - end - address + if iface + address_for(iface) + else + service_config['host'] + end end private diff --git a/libraries/parse.rb b/libraries/parse.rb index 604336e9..ad0565dd 100644 --- a/libraries/parse.rb +++ b/libraries/parse.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: parse diff --git a/libraries/passwords.rb b/libraries/passwords.rb index 8f122910..f29feece 100644 --- a/libraries/passwords.rb +++ b/libraries/passwords.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: passwords diff --git a/libraries/provider_database_mysql.rb b/libraries/provider_database_mysql.rb deleted file mode 100644 index a7197dae..00000000 --- a/libraries/provider_database_mysql.rb +++ /dev/null @@ -1,164 +0,0 @@ -# -# Author:: Seth Chisamore () -# Author:: Sean OMeara () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -class Chef - class Provider - class Database - class Mysql < Chef::Provider::LWRPBase - action :create do - # test - schema_present = nil - - begin - test_sql = 'SHOW SCHEMAS;' - Chef::Log.debug("#{new_resource.name}: Performing query [#{test_sql}]") - test_sql_results = test_client.query(test_sql) - test_sql_results.each do |r| - schema_present = true if r['Database'] == new_resource.database_name - end - ensure - close_test_client - end - - # repair - unless schema_present - converge_by "Creating schema '#{new_resource.database_name}'" do - begin - repair_sql = "CREATE SCHEMA IF NOT EXISTS `#{new_resource.database_name}`" - repair_sql += " CHARACTER SET = #{new_resource.encoding}" if new_resource.encoding - repair_sql += " COLLATE = #{new_resource.collation}" if new_resource.collation - Chef::Log.debug("#{new_resource.name}: Performing query [#{repair_sql}]") - repair_client.query(repair_sql) - ensure - close_repair_client - end - end - end - end - - action :drop do - # test - schema_present = nil - - begin - test_sql = 'SHOW SCHEMAS;' - Chef::Log.debug("Performing query [#{test_sql}]") - test_sql_results = test_client.query(test_sql) - test_sql_results.each do |r| - schema_present = true if r['Database'] == new_resource.database_name - end - ensure - close_test_client - end - - # repair - if schema_present - converge_by "Dropping schema '#{new_resource.database_name}'" do - begin - repair_sql = "DROP SCHEMA IF EXISTS `#{new_resource.database_name}`" - Chef::Log.debug("Performing query [#{repair_sql}]") - repair_client.query(repair_sql) - ensure - close_repair_client - end - end - end - end - - action :query do - begin - query_sql = new_resource.sql_query - Chef::Log.debug("Performing query [#{query_sql}]") - query_client.query(query_sql) - ensure - close_query_client - end - end - - private - - def test_client - require 'mysql2' - @test_client ||= - Mysql2::Client.new( - host: new_resource.connection[:host], - socket: new_resource.connection[:socket], - username: new_resource.connection[:username], - password: new_resource.connection[:password], - port: new_resource.connection[:port], - default_file: new_resource.connection[:default_file], - default_group: new_resource.connection[:default_group] - ) - end - - def close_test_client - @test_client.close if @test_client - rescue Mysql2::Error - @test_client = nil - end - - def repair_client - require 'mysql2' - @repair_client ||= - Mysql2::Client.new( - host: new_resource.connection[:host], - socket: new_resource.connection[:socket], - username: new_resource.connection[:username], - password: new_resource.connection[:password], - port: new_resource.connection[:port], - default_file: new_resource.connection[:default_file], - default_group: new_resource.connection[:default_group] - ) - end - - def close_repair_client - @repair_client.close if @repair_client - rescue Mysql2::Error - @repair_client = nil - end - - def query_client - require 'mysql2' - @query_client ||= - Mysql2::Client.new( - host: new_resource.connection[:host], - socket: new_resource.connection[:socket], - username: new_resource.connection[:username], - password: new_resource.connection[:password], - port: new_resource.connection[:port], - default_file: new_resource.connection[:default_file], - default_group: new_resource.connection[:default_group], - flags: new_resource.connection[:flags], - database: new_resource.database_name - ) - end - - def close_query_client - @query_client.close if @query_client - rescue Mysql2::Error - @query_client = nil - end - end - end - end -end diff --git a/libraries/provider_database_mysql_user.rb b/libraries/provider_database_mysql_user.rb deleted file mode 100644 index bc8389bc..00000000 --- a/libraries/provider_database_mysql_user.rb +++ /dev/null @@ -1,382 +0,0 @@ -# -# Author:: Seth Chisamore () -# Author:: Sean OMeara () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -require File.join(File.dirname(__FILE__), 'provider_database_mysql') - -class Chef - class Provider - class Database - class MysqlUser < Chef::Provider::Database::Mysql - action :create do - # test - user_present = nil - begin - test_sql = "SELECT User,Host from mysql.user WHERE User='#{new_resource.username}' AND Host='#{new_resource.host}';" - test_sql_results = test_client.query(test_sql) - test_sql_results.each do |r| - user_present = true if r['User'] == new_resource.username - end - - password_up_to_date = !user_present || test_user_password - ensure - close_test_client - end - - # repair - unless user_present - converge_by "Creating user '#{new_resource.username}'@'#{new_resource.host}'" do - begin - repair_sql = "CREATE USER '#{new_resource.username}'@'#{new_resource.host}'" - if new_resource.password - repair_sql += ' IDENTIFIED BY ' - repair_sql += if new_resource.password.is_a?(HashedPassword) - " PASSWORD '#{new_resource.password}'" - else - " '#{new_resource.password}'" - end - end - repair_client.query(repair_sql) - ensure - close_repair_client - end - end - end - - update_user_password unless password_up_to_date - end - - action :drop do - # test - user_present = nil - begin - test_sql = 'SELECT User,Host' - test_sql += ' from mysql.user' - test_sql += " WHERE User='#{new_resource.username}'" - test_sql += " AND Host='#{new_resource.host}'" - test_sql_results = test_client.query test_sql - test_sql_results.each do |r| - user_present = true if r['User'] == new_resource.username - end - ensure - close_test_client - end - - # repair - if user_present - converge_by "Dropping user '#{new_resource.username}'@'#{new_resource.host}'" do - begin - repair_sql = 'DROP USER' - repair_sql += " '#{new_resource.username}'@'#{new_resource.host}'" - repair_client.query repair_sql - ensure - close_repair_client - end - end - end - end - - action :grant do - # gratuitous function - def ishash? - return true if /(\A\*[0-9A-F]{40}\z)/i =~ new_resource.password - end - - db_name = new_resource.database_name ? "`#{new_resource.database_name}`" : '*' - tbl_name = new_resource.table ? new_resource.table : '*' - test_table = new_resource.database_name ? 'mysql.db' : 'mysql.user' - - # Test - incorrect_privs = nil - begin - test_sql = "SELECT * from #{test_table}" - test_sql += " WHERE User='#{new_resource.username}'" - test_sql += " AND Host='#{new_resource.host}'" - test_sql += " AND Db='#{new_resource.database_name}'" if new_resource.database_name - test_sql_results = test_client.query test_sql - - incorrect_privs = true if test_sql_results.size.zero? - # These should all be 'Y' - test_sql_results.each do |r| - desired_privs.each do |p| - key = p.to_s.capitalize.tr(' ', '_').gsub('Replication_', 'Repl_').gsub('Create_temporary_tables', 'Create_tmp_table').gsub('Show_databases', 'Show_db') - key = "#{key}_priv" - incorrect_privs = true if r[key] != 'Y' - end - end - - password_up_to_date = incorrect_privs || test_user_password - ensure - close_test_client - end - - # Repair - if incorrect_privs - converge_by "Granting privs for '#{new_resource.username}'@'#{new_resource.host}'" do - begin - repair_sql = "GRANT #{new_resource.privileges.join(',')}" - repair_sql += " ON #{db_name}.#{tbl_name}" - repair_sql += " TO '#{new_resource.username}'@'#{new_resource.host}' IDENTIFIED BY" - repair_sql += if new_resource.password.is_a?(HashedPassword) - " PASSWORD '#{new_resource.password}'" - else - " '#{new_resource.password}'" - end - repair_sql += ' REQUIRE SSL' if new_resource.require_ssl - repair_sql += ' REQUIRE X509' if new_resource.require_x509 - repair_sql += ' WITH GRANT OPTION' if new_resource.grant_option - - redacted_sql = redact_password(repair_sql, new_resource.password) - Chef::Log.debug("#{@new_resource}: granting with sql [#{redacted_sql}]") - repair_client.query(repair_sql) - repair_client.query('FLUSH PRIVILEGES') - ensure - close_repair_client - end - end - else - # The grants are correct, but perhaps the password needs updating? - update_user_password unless password_up_to_date - end - end - - action :revoke do - db_name = new_resource.database_name ? "`#{new_resource.database_name}`" : '*' - tbl_name = new_resource.table ? new_resource.table : '*' - test_table = new_resource.database_name ? 'mysql.db' : 'mysql.user' - - privs_to_revoke = [] - begin - test_sql = "SELECT * from #{test_table}" - test_sql += " WHERE User='#{new_resource.username}'" - test_sql += " AND Host='#{new_resource.host}'" - test_sql += " AND Db='#{new_resource.database_name}'" if new_resource.database_name - test_sql_results = test_client.query test_sql - - # These should all be 'N' - test_sql_results.each do |r| - desired_privs.each do |p| - key = p.to_s.capitalize.tr(' ', '_').gsub('Replication_', 'Repl_').gsub('Create_temporary_tables', 'Create_tmp_table').gsub('Show_databases', 'Show_db') - key = "#{key}_priv" - privs_to_revoke << revokify_key(p) if r[key] != 'N' - end - end - ensure - close_test_client - end - - # Repair - unless privs_to_revoke.empty? - converge_by "Revoking privs for '#{new_resource.username}'@'#{new_resource.host}'" do - begin - revoke_statement = "REVOKE #{privs_to_revoke.join(',')}" - revoke_statement += " ON #{db_name}.#{tbl_name}" - revoke_statement += " FROM `#{@new_resource.username}`@`#{@new_resource.host}` " - - Chef::Log.debug("#{@new_resource}: revoking access with statement [#{revoke_statement}]") - repair_client.query(revoke_statement) - repair_client.query('FLUSH PRIVILEGES') - ensure - close_repair_client - end - end - end - end - - private - - def desired_privs - possible_global_privs = [ - :select, - :insert, - :update, - :delete, - :create, - :drop, - :references, - :index, - :alter, - :create_tmp_table, - :lock_tables, - :create_view, - :show_view, - :create_routine, - :alter_routine, - :execute, - :event, - :trigger, - :reload, - :shutdown, - :process, - :file, - :show_db, - :super, - :repl_slave, - :repl_client, - :create_user, - ] - possible_db_privs = [ - :select, - :insert, - :update, - :delete, - :create, - :drop, - :references, - :index, - :alter, - :create_tmp_table, - :lock_tables, - :create_view, - :show_view, - :create_routine, - :alter_routine, - :execute, - :event, - :trigger, - ] - - # convert :all to the individual db or global privs - desired_privs = if new_resource.privileges == [:all] && new_resource.database_name - possible_db_privs - elsif new_resource.privileges == [:all] - possible_global_privs - else - new_resource.privileges - end - desired_privs - end - - def test_client - require 'mysql2' - @test_client ||= - Mysql2::Client.new( - host: new_resource.connection[:host], - socket: new_resource.connection[:socket], - username: new_resource.connection[:username], - password: new_resource.connection[:password], - port: new_resource.connection[:port], - default_file: new_resource.connection[:default_file], - default_group: new_resource.connection[:default_group] - ) - end - - def close_test_client - @test_client.close if @test_client - rescue Mysql2::Error - @test_client = nil - end - - def repair_client - require 'mysql2' - @repair_client ||= - Mysql2::Client.new( - host: new_resource.connection[:host], - socket: new_resource.connection[:socket], - username: new_resource.connection[:username], - password: new_resource.connection[:password], - port: new_resource.connection[:port], - default_file: new_resource.connection[:default_file], - default_group: new_resource.connection[:default_group] - ) - end - - def close_repair_client - @repair_client.close if @repair_client - rescue Mysql2::Error - @repair_client = nil - end - - def revokify_key(key) - return '' if key.nil? - - # Some keys need to be translated as outlined by the table found here: - # https://dev.mysql.com/doc/refman/5.7/en/privileges-provided.html - result = key.to_s.downcase.tr('_', ' ').gsub('repl ', 'replication ').gsub('create tmp table', 'create temporary tables').gsub('show db', 'show databases') - result = result.gsub(/ priv$/, '') - result - end - - def test_user_password - if database_has_password_column(test_client) - test_sql = 'SELECT User,Host,Password FROM mysql.user ' \ - "WHERE User='#{new_resource.username}' AND Host='#{new_resource.host}' " - test_sql += if new_resource.password.is_a? HashedPassword - "AND Password='#{new_resource.password}'" - else - "AND Password=PASSWORD('#{new_resource.password}')" - end - else - test_sql = 'SELECT User,Host,authentication_string FROM mysql.user ' \ - "WHERE User='#{new_resource.username}' AND Host='#{new_resource.host}' " \ - "AND plugin='mysql_native_password' " - test_sql += if new_resource.password.is_a? HashedPassword - "AND authentication_string='#{new_resource.password}'" - else - "AND authentication_string=PASSWORD('#{new_resource.password}')" - end - end - test_client.query(test_sql).size > 0 - end - - def update_user_password - converge_by "Updating password of user '#{new_resource.username}'@'#{new_resource.host}'" do - begin - if database_has_password_column(repair_client) - repair_sql = "SET PASSWORD FOR '#{new_resource.username}'@'#{new_resource.host}' = " - repair_sql += if new_resource.password.is_a? HashedPassword - "'#{new_resource.password}'" - else - " PASSWORD('#{new_resource.password}')" - end - else - # "ALTER USER is now the preferred statement for assigning passwords." - # http://dev.mysql.com/doc/refman/5.7/en/set-password.html - repair_sql = "ALTER USER '#{new_resource.username}'@'#{new_resource.host}' " - repair_sql += if new_resource.password.is_a? HashedPassword - "IDENTIFIED WITH mysql_native_password AS '#{new_resource.password}'" - else - "IDENTIFIED BY '#{new_resource.password}'" - end - end - repair_client.query(repair_sql) - ensure - close_repair_client - end - end - end - - def database_has_password_column(client) - client.query('SHOW COLUMNS FROM mysql.user WHERE Field="Password"').size > 0 - end - - def redact_password(query, password) - if password.nil? || password == '' - query - else - query.gsub(password, 'REDACTED') - end - end - end - end - end -end diff --git a/libraries/resource_database.rb b/libraries/resource_database.rb deleted file mode 100644 index 0fa7fc64..00000000 --- a/libraries/resource_database.rb +++ /dev/null @@ -1,58 +0,0 @@ -# -# Author:: Seth Chisamore () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -require 'chef/resource' - -class Chef - class Resource - class Database < Chef::Resource - resource_name :database - provides :database - - default_action :create - - def initialize(name, run_context = nil) - super - @database_name = name - @allowed_actions.push(:create, :drop, :query) - end - - property :database_name, String - property :connection, required: true - property :sql, [String, Proc] - property :template, String, default: 'DEFAULT' - property :collation, String - property :encoding, String, default: 'DEFAULT' - property :tablespace, String, default: 'DEFAULT' - property :connection_limit, String, default: '-1' - property :owner, String - - def sql_query - if sql.is_a?(Proc) - sql.call - else - sql - end - end - end - end -end diff --git a/libraries/resource_database_user.rb b/libraries/resource_database_user.rb deleted file mode 100644 index cc4b0750..00000000 --- a/libraries/resource_database_user.rb +++ /dev/null @@ -1,59 +0,0 @@ -# -# Author:: Seth Chisamore () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -require File.join(File.dirname(__FILE__), 'resource_database') - -class Chef - class Resource - class DatabaseUser < Chef::Resource::Database - resource_name :database_user - provides :database_user - - default_action :create - - def initialize(name, run_context = nil) - super - @username = name - - @database_name = nil - @table = nil - @host = 'localhost' - @privileges = [:all] - @grant_option = false - @require_ssl = false - @require_x509 = false - - @allowed_actions.push(:create, :drop, :grant, :revoke) - end - - property :database_name, String - property :username, String - property :require_ssl, [true, false] - property :require_x509, [true, false] - property :password, String - property :table, String - property :host, String - property :privileges, Array - property :grant_option, [true, false], default: false - end - end -end diff --git a/libraries/resource_mysql_database.rb b/libraries/resource_mysql_database.rb deleted file mode 100644 index 0e5097db..00000000 --- a/libraries/resource_mysql_database.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -# Author:: Seth Chisamore () -# Author:: Sean OMeara () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -require File.join(File.dirname(__FILE__), 'provider_database_mysql') - -class Chef - class Resource - class MysqlDatabase < Chef::Resource::Database - resource_name :mysql_database - provides :mysql_database - - def initialize(name, run_context = nil) - super - @provider = Chef::Provider::Database::Mysql - end - end - end -end diff --git a/libraries/resource_mysql_database_user.rb b/libraries/resource_mysql_database_user.rb deleted file mode 100644 index 89872bac..00000000 --- a/libraries/resource_mysql_database_user.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Author:: Seth Chisamore () -# Copyright:: 2011-2016, Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# this file is originally from the database cookbook, preserved for legacy -# purposes until the functionality can be refactored into a custom resource. -# Original: https://github.com/chef-boneyard/database - -require File.join(File.dirname(__FILE__), 'resource_database_user') -require File.join(File.dirname(__FILE__), 'provider_database_mysql_user') - -class Chef - class Resource - class MysqlDatabaseUser < Chef::Resource::DatabaseUser - resource_name :mysql_database_user - provides :mysql_database_user - - def initialize(name, run_context = nil) - super - @provider = Chef::Provider::Database::MysqlUser - end - property :password, [String, HashedPassword] - end - end -end diff --git a/libraries/search.rb b/libraries/search.rb index b9c6f74f..140de4ce 100644 --- a/libraries/search.rb +++ b/libraries/search.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # library:: search @@ -36,7 +35,7 @@ module ::Openstack sleep 2**count count += 1 end - resp ? resp : [] + resp || [] end # Returns the value for ['openstack']['memcached_servers'] when diff --git a/libraries/uri.rb b/libraries/uri.rb index d8b31ef6..d4138a45 100644 --- a/libraries/uri.rb +++ b/libraries/uri.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - # # Cookbook:: openstack-common # library:: uri @@ -35,7 +33,7 @@ module ::Openstack ::URI.parse Addressable::URI.encode(hash['uri']) else host = hash['host'] - scheme = hash['scheme'] ? hash['scheme'] : 'http' + scheme = hash['scheme'] || 'http' port = hash['port'] # Returns nil if missing, which is fine. path = hash['path'] # Returns nil if missing, which is fine. ::URI::Generic.new scheme, nil, host, port, nil, path, nil, nil, nil @@ -46,7 +44,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.empty? + return if paths.empty? leadingslash = paths[0][0] == '/' ? '/' : '' trailingslash = paths[-1][-1] == '/' ? '/' : '' paths.map! { |path| path.sub(%r{^\/+}, '').sub(%r{\/+$}, '') } diff --git a/recipes/client.rb b/recipes/client.rb index 50536efc..07c5cade 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # Recipe:: client diff --git a/recipes/completions.rb b/recipes/completions.rb index 6996ba1d..8ec2cefa 100644 --- a/recipes/completions.rb +++ b/recipes/completions.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # Recipe:: completions diff --git a/recipes/default.rb b/recipes/default.rb index 645e2de4..6b855c3f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # library:: default diff --git a/recipes/etcd.rb b/recipes/etcd.rb index bffb0050..82a2e224 100644 --- a/recipes/etcd.rb +++ b/recipes/etcd.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # library:: etcd diff --git a/recipes/logging.rb b/recipes/logging.rb index 565aa3f1..4934e56e 100644 --- a/recipes/logging.rb +++ b/recipes/logging.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # library:: logging diff --git a/recipes/sysctl.rb b/recipes/sysctl.rb index 3555b303..7712bc44 100644 --- a/recipes/sysctl.rb +++ b/recipes/sysctl.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # # Cookbook:: openstack-common # recipe:: sysctl diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 6730aacc..21e5d1c3 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'cli' diff --git a/spec/client-redhat_spec.rb b/spec/client-redhat_spec.rb index 02dfc886..c7fa803c 100644 --- a/spec/client-redhat_spec.rb +++ b/spec/client-redhat_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::client' do diff --git a/spec/client_spec.rb b/spec/client_spec.rb index af0727d7..48a59023 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::client' do diff --git a/spec/completions_spec.rb b/spec/completions_spec.rb index d422f5b7..4fd038ba 100644 --- a/spec/completions_spec.rb +++ b/spec/completions_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::completions' do diff --git a/spec/config_helpers_spec.rb b/spec/config_helpers_spec.rb index 46b3ef9a..79044d64 100644 --- a/spec/config_helpers_spec.rb +++ b/spec/config_helpers_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'config_helpers' diff --git a/spec/database_provider_spec.rb b/spec/database_provider_spec.rb index d23fba4d..bb2e4bd0 100644 --- a/spec/database_provider_spec.rb +++ b/spec/database_provider_spec.rb @@ -1,5 +1,3 @@ -# encoding: UTF-8 - require_relative 'spec_helper' describe 'test-openstack-common-database::default' do diff --git a/spec/default-redhat_spec.rb b/spec/default-redhat_spec.rb index c161e3cd..51b828ef 100644 --- a/spec/default-redhat_spec.rb +++ b/spec/default-redhat_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::default' do diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 7cfa3be3..683ad855 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::default' do diff --git a/spec/endpoints_spec.rb b/spec/endpoints_spec.rb index 3c2d864c..ac51d1ab 100644 --- a/spec/endpoints_spec.rb +++ b/spec/endpoints_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'uri' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'endpoints' diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb index 4ef4b729..72700832 100644 --- a/spec/logging_spec.rb +++ b/spec/logging_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::logging' do diff --git a/spec/network_spec.rb b/spec/network_spec.rb index 45b8b350..f2f2e3a1 100644 --- a/spec/network_spec.rb +++ b/spec/network_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'network' diff --git a/spec/parse_spec.rb b/spec/parse_spec.rb index 05f3b370..4f050626 100644 --- a/spec/parse_spec.rb +++ b/spec/parse_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require 'uri' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'parse' diff --git a/spec/password_spec.rb b/spec/password_spec.rb index 99336671..ca6aadb8 100644 --- a/spec/password_spec.rb +++ b/spec/password_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'passwords' require 'chef-vault' diff --git a/spec/search_spec.rb b/spec/search_spec.rb index 8bde4f11..6eabdc22 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'search' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3a15cfcc..38ebf23f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require 'chefspec' require 'chefspec/berkshelf' diff --git a/spec/sysctl_spec.rb b/spec/sysctl_spec.rb index 216e3693..fa4420e8 100644 --- a/spec/sysctl_spec.rb +++ b/spec/sysctl_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' describe 'openstack-common::sysctl' do diff --git a/spec/uri_spec.rb b/spec/uri_spec.rb index 4a706472..f4410ebe 100644 --- a/spec/uri_spec.rb +++ b/spec/uri_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'uri' require 'uri' diff --git a/spec/wrappers_spec.rb b/spec/wrappers_spec.rb index dc02a178..8b377c42 100644 --- a/spec/wrappers_spec.rb +++ b/spec/wrappers_spec.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'wrappers'