From 43cd21b687a8a46b59be410de8be5f0bf133d1dc Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 11 Feb 2016 17:33:29 -0800 Subject: chefstyle catchup for ohai there's still a few cops that are unaddressed by this change, so it won't be clean after merging this. --- Gemfile | 2 +- Rakefile | 8 +- bin/ohai | 7 +- lib/ohai.rb | 8 +- lib/ohai/application.rb | 13 +- lib/ohai/common/dmi.rb | 112 ++-- lib/ohai/config.rb | 20 +- lib/ohai/dsl.rb | 6 +- lib/ohai/dsl/plugin.rb | 10 +- lib/ohai/dsl/plugin/versionvi.rb | 1 - lib/ohai/dsl/plugin/versionvii.rb | 1 + lib/ohai/hints.rb | 2 +- lib/ohai/loader.rb | 12 +- lib/ohai/log.rb | 2 +- lib/ohai/mash.rb | 5 +- lib/ohai/mixin/command.rb | 63 +- lib/ohai/mixin/dmi_decode.rb | 16 +- lib/ohai/mixin/ec2_metadata.rb | 62 +- lib/ohai/mixin/gce_metadata.rb | 18 +- lib/ohai/mixin/network_constants.rb | 2 +- lib/ohai/mixin/os.rb | 6 +- lib/ohai/mixin/seconds_to_human.rb | 2 - lib/ohai/mixin/softlayer_metadata.rb | 20 +- lib/ohai/mixin/string.rb | 4 +- lib/ohai/plugin_config.rb | 2 +- lib/ohai/plugins/aix/cpu.rb | 4 +- lib/ohai/plugins/aix/filesystem.rb | 4 +- lib/ohai/plugins/aix/memory.rb | 4 +- lib/ohai/plugins/aix/network.rb | 19 +- lib/ohai/plugins/aix/os.rb | 4 +- lib/ohai/plugins/aix/uptime.rb | 6 +- lib/ohai/plugins/aix/virtualization.rb | 46 +- lib/ohai/plugins/azure.rb | 8 +- lib/ohai/plugins/bsd/virtualization.rb | 44 +- lib/ohai/plugins/c.rb | 6 +- lib/ohai/plugins/chef.rb | 2 +- lib/ohai/plugins/cloud.rb | 119 ++-- lib/ohai/plugins/cloud_v2.rb | 76 ++- lib/ohai/plugins/darwin/cpu.rb | 2 +- lib/ohai/plugins/darwin/filesystem2.rb | 10 +- lib/ohai/plugins/darwin/memory.rb | 11 +- lib/ohai/plugins/darwin/network.rb | 16 +- lib/ohai/plugins/darwin/system_profiler.rb | 65 +- lib/ohai/plugins/darwin/virtualization.rb | 18 +- lib/ohai/plugins/digital_ocean.rb | 26 +- lib/ohai/plugins/dmi.rb | 12 +- lib/ohai/plugins/dragonflybsd/cpu.rb | 4 +- lib/ohai/plugins/dragonflybsd/memory.rb | 1 - lib/ohai/plugins/dragonflybsd/network.rb | 8 +- lib/ohai/plugins/dragonflybsd/os.rb | 2 +- lib/ohai/plugins/ec2.rb | 12 +- lib/ohai/plugins/elixir.rb | 2 +- lib/ohai/plugins/erlang.rb | 6 +- lib/ohai/plugins/eucalyptus.rb | 8 +- lib/ohai/plugins/freebsd/cpu.rb | 4 +- lib/ohai/plugins/freebsd/memory.rb | 1 - lib/ohai/plugins/freebsd/network.rb | 8 +- lib/ohai/plugins/freebsd/os.rb | 2 +- lib/ohai/plugins/gce.rb | 8 +- lib/ohai/plugins/hostname.rb | 14 +- lib/ohai/plugins/init_package.rb | 2 +- lib/ohai/plugins/ip_scopes.rb | 18 +- lib/ohai/plugins/joyent.rb | 14 +- lib/ohai/plugins/kernel.rb | 16 +- lib/ohai/plugins/linode.rb | 8 +- lib/ohai/plugins/linux/cpu.rb | 8 +- lib/ohai/plugins/linux/filesystem.rb | 32 +- lib/ohai/plugins/linux/filesystem2.rb | 30 +- lib/ohai/plugins/linux/mdadm.rb | 6 +- lib/ohai/plugins/linux/network.rb | 46 +- lib/ohai/plugins/linux/platform.rb | 48 +- lib/ohai/plugins/linux/virtualization.rb | 14 +- lib/ohai/plugins/mono.rb | 2 +- lib/ohai/plugins/netbsd/cpu.rb | 2 +- lib/ohai/plugins/netbsd/network.rb | 4 +- lib/ohai/plugins/network.rb | 28 +- lib/ohai/plugins/network_listeners.rb | 4 +- lib/ohai/plugins/ohai.rb | 6 +- lib/ohai/plugins/openbsd/cpu.rb | 8 +- lib/ohai/plugins/openbsd/memory.rb | 8 +- lib/ohai/plugins/openbsd/network.rb | 6 +- lib/ohai/plugins/openstack.rb | 24 +- lib/ohai/plugins/os.rb | 4 +- lib/ohai/plugins/packages.rb | 44 +- lib/ohai/plugins/passwd.rb | 8 +- lib/ohai/plugins/powershell.rb | 18 +- lib/ohai/plugins/ps.rb | 4 +- lib/ohai/plugins/python.rb | 2 +- lib/ohai/plugins/rackspace.rb | 22 +- lib/ohai/plugins/root_group.rb | 8 +- lib/ohai/plugins/ruby.rb | 12 +- lib/ohai/plugins/rust.rb | 2 +- lib/ohai/plugins/sigar/cpu.rb | 2 +- lib/ohai/plugins/sigar/filesystem.rb | 2 +- lib/ohai/plugins/sigar/network.rb | 26 +- lib/ohai/plugins/sigar/network_route.rb | 8 +- lib/ohai/plugins/softlayer.rb | 8 +- lib/ohai/plugins/solaris2/cpu.rb | 38 +- lib/ohai/plugins/solaris2/dmi.rb | 124 ++-- lib/ohai/plugins/solaris2/filesystem.rb | 26 +- lib/ohai/plugins/solaris2/memory.rb | 4 +- lib/ohai/plugins/solaris2/network.rb | 10 +- lib/ohai/plugins/solaris2/virtualization.rb | 36 +- lib/ohai/plugins/ssh_host_key.rb | 4 +- lib/ohai/plugins/uptime.rb | 9 +- lib/ohai/plugins/virtualbox.rb | 4 +- lib/ohai/plugins/virtualization.rb | 34 +- lib/ohai/plugins/vmware.rb | 4 +- lib/ohai/plugins/windows/cpu.rb | 28 +- lib/ohai/plugins/windows/drivers.rb | 16 +- lib/ohai/plugins/windows/filesystem.rb | 8 +- lib/ohai/plugins/windows/memory.rb | 2 +- lib/ohai/plugins/windows/network.rb | 18 +- lib/ohai/plugins/windows/platform.rb | 3 +- lib/ohai/plugins/windows/virtualization.rb | 34 +- lib/ohai/provides_map.rb | 14 +- lib/ohai/runner.rb | 6 +- lib/ohai/system.rb | 43 +- lib/ohai/util/file_helper.rb | 3 +- lib/ohai/util/ip_helper.rb | 8 +- lib/ohai/util/win32.rb | 10 +- lib/ohai/util/win32/group_helper.rb | 9 +- lib/ohai/version.rb | 2 +- ohai.gemspec | 10 +- .../common/ohai_plugin_common.rb | 61 +- .../common/ohai_plugin_common_spec.rb | 24 +- platform_simulation_specs/plugins/c_spec.rb | 36 +- platform_simulation_specs/plugins/erlang_spec.rb | 26 +- platform_simulation_specs/plugins/go_spec.rb | 18 +- platform_simulation_specs/plugins/groovy_spec.rb | 33 +- platform_simulation_specs/plugins/java_spec.rb | 48 +- platform_simulation_specs/plugins/kernel_spec.rb | 12 +- platform_simulation_specs/plugins/lua_spec.rb | 23 +- platform_simulation_specs/plugins/nodejs_spec.rb | 18 +- platform_simulation_specs/plugins/perl_spec.rb | 22 +- platform_simulation_specs/plugins/php_spec.rb | 26 +- platform_simulation_specs/plugins/python_spec.rb | 25 +- platform_simulation_specs/tools/grab_data.rb | 18 +- spec/functional/application_spec.rb | 46 +- spec/functional/loader_spec.rb | 2 +- spec/functional/plugins/powershell_spec.rb | 26 +- spec/functional/plugins/root_group_spec.rb | 10 +- spec/ohai_spec.rb | 2 +- spec/spec_helper.rb | 18 +- spec/support/integration_helper.rb | 14 +- spec/support/platform_helpers.rb | 2 +- spec/unit/application_spec.rb | 34 +- spec/unit/config_spec.rb | 4 +- spec/unit/dsl/plugin_spec.rb | 56 +- spec/unit/hints_spec.rb | 6 +- spec/unit/loader_spec.rb | 18 +- spec/unit/mixin/command_spec.rb | 10 +- spec/unit/mixin/ec2_metadata_spec.rb | 12 +- spec/unit/mixin/softlayer_metadata_spec.rb | 42 +- spec/unit/plugin_config_spec.rb | 10 +- spec/unit/plugins/abort_spec.rb | 6 +- spec/unit/plugins/aix/cpu_spec.rb | 2 +- spec/unit/plugins/aix/filesystem_spec.rb | 50 +- spec/unit/plugins/aix/hostname_spec.rb | 3 +- spec/unit/plugins/aix/kernel_spec.rb | 6 +- spec/unit/plugins/aix/memory_spec.rb | 16 +- spec/unit/plugins/aix/network_spec.rb | 76 +-- spec/unit/plugins/aix/os_spec.rb | 3 +- spec/unit/plugins/aix/platform_spec.rb | 2 +- spec/unit/plugins/aix/uptime_spec.rb | 2 +- spec/unit/plugins/aix/virtualization_spec.rb | 22 +- spec/unit/plugins/azure_spec.rb | 101 ++- spec/unit/plugins/bsd/filesystem_spec.rb | 2 +- spec/unit/plugins/bsd/virtualization_spec.rb | 8 +- spec/unit/plugins/c_spec.rb | 24 +- spec/unit/plugins/chef_spec.rb | 4 +- spec/unit/plugins/cloud_spec.rb | 74 +-- spec/unit/plugins/cloud_v2_spec.rb | 129 ++-- spec/unit/plugins/darwin/cpu_spec.rb | 3 +- spec/unit/plugins/darwin/filesystem2_spec.rb | 14 +- spec/unit/plugins/darwin/filesystem_spec.rb | 10 +- spec/unit/plugins/darwin/hostname_spec.rb | 5 +- spec/unit/plugins/darwin/kernel_spec.rb | 16 +- spec/unit/plugins/darwin/memory_spec.rb | 10 +- spec/unit/plugins/darwin/network_spec.rb | 705 ++++++++++----------- spec/unit/plugins/darwin/platform_spec.rb | 3 +- spec/unit/plugins/darwin/system_profiler_spec.rb | 6 +- spec/unit/plugins/darwin/virtualization_spec.rb | 12 +- spec/unit/plugins/digital_ocean_spec.rb | 72 +-- spec/unit/plugins/ec2_spec.rb | 80 +-- spec/unit/plugins/elixir_spec.rb | 3 +- spec/unit/plugins/erlang_spec.rb | 4 +- spec/unit/plugins/eucalyptus_spec.rb | 38 +- spec/unit/plugins/fail_spec.rb | 4 +- spec/unit/plugins/freebsd/cpu_spec.rb | 28 +- spec/unit/plugins/freebsd/hostname_spec.rb | 3 +- spec/unit/plugins/freebsd/kernel_spec.rb | 5 +- spec/unit/plugins/freebsd/os_spec.rb | 9 +- spec/unit/plugins/freebsd/platform_spec.rb | 3 +- spec/unit/plugins/gce_spec.rb | 18 +- spec/unit/plugins/go_spec.rb | 2 +- spec/unit/plugins/groovy_spec.rb | 3 +- spec/unit/plugins/hostname_spec.rb | 3 +- spec/unit/plugins/init_package_spec.rb | 2 +- spec/unit/plugins/ip_scopes_spec.rb | 76 +-- spec/unit/plugins/java_spec.rb | 4 +- spec/unit/plugins/joyent_spec.rb | 20 +- spec/unit/plugins/kernel_spec.rb | 23 +- spec/unit/plugins/linode_spec.rb | 58 +- spec/unit/plugins/linux/block_device_spec.rb | 42 +- spec/unit/plugins/linux/cpu_spec.rb | 6 +- spec/unit/plugins/linux/filesystem2_spec.rb | 14 +- spec/unit/plugins/linux/filesystem_spec.rb | 171 +++-- spec/unit/plugins/linux/hostname_spec.rb | 4 +- spec/unit/plugins/linux/kernel_spec.rb | 2 +- spec/unit/plugins/linux/lsb_spec.rb | 3 +- spec/unit/plugins/linux/mdadm_spec.rb | 8 +- spec/unit/plugins/linux/memory_spec.rb | 62 +- spec/unit/plugins/linux/platform_spec.rb | 129 ++-- spec/unit/plugins/linux/uptime_spec.rb | 3 +- spec/unit/plugins/linux/virtualization_spec.rb | 84 +-- spec/unit/plugins/lua_spec.rb | 3 +- spec/unit/plugins/mono_spec.rb | 3 +- spec/unit/plugins/netbsd/hostname_spec.rb | 3 +- spec/unit/plugins/netbsd/kernel_spec.rb | 3 +- spec/unit/plugins/netbsd/platform_spec.rb | 2 +- spec/unit/plugins/network_spec.rb | 236 +++---- spec/unit/plugins/nodejs_spec.rb | 2 +- spec/unit/plugins/ohai_spec.rb | 2 +- spec/unit/plugins/ohai_time_spec.rb | 3 +- spec/unit/plugins/openbsd/hostname_spec.rb | 3 +- spec/unit/plugins/openbsd/kernel_spec.rb | 3 +- spec/unit/plugins/openbsd/platform_spec.rb | 3 +- spec/unit/plugins/openstack_spec.rb | 72 +-- spec/unit/plugins/os_spec.rb | 15 +- spec/unit/plugins/packages_spec.rb | 236 +++---- spec/unit/plugins/passwd_spec.rb | 36 +- spec/unit/plugins/perl_spec.rb | 2 +- spec/unit/plugins/php_spec.rb | 8 +- spec/unit/plugins/platform_spec.rb | 17 +- spec/unit/plugins/powershell_spec.rb | 6 +- spec/unit/plugins/python_spec.rb | 2 +- spec/unit/plugins/rackspace_spec.rb | 134 ++-- spec/unit/plugins/root_group_spec.rb | 52 +- spec/unit/plugins/ruby_spec.rb | 29 +- spec/unit/plugins/rust_spec.rb | 4 +- spec/unit/plugins/sigar/network_route_spec.rb | 72 +-- spec/unit/plugins/softlayer_spec.rb | 20 +- spec/unit/plugins/solaris2/cpu_spec.rb | 41 +- spec/unit/plugins/solaris2/dmi_spec.rb | 11 +- spec/unit/plugins/solaris2/filesystem.rb | 10 +- spec/unit/plugins/solaris2/hostname_spec.rb | 2 +- spec/unit/plugins/solaris2/kernel_spec.rb | 6 +- spec/unit/plugins/solaris2/memory_spec.rb | 10 +- spec/unit/plugins/solaris2/network_spec.rb | 15 +- spec/unit/plugins/solaris2/platform_spec.rb | 2 +- spec/unit/plugins/solaris2/virtualization_spec.rb | 8 +- spec/unit/plugins/solaris2/zpools_spec.rb | 12 +- spec/unit/plugins/ssh_host_keys_spec.rb | 2 +- spec/unit/plugins/virtualbox_spec.rb | 38 +- spec/unit/plugins/vmware_spec.rb | 56 +- spec/unit/plugins/windows/cpu_spec.rb | 96 +-- spec/unit/plugins/windows/memory_spec.rb | 10 +- spec/unit/plugins/windows/virtualization_spec.rb | 326 +++++----- spec/unit/provides_map_spec.rb | 20 +- spec/unit/runner_spec.rb | 20 +- spec/unit/system_spec.rb | 38 +- spec/unit/util/file_helper_spec.rb | 11 +- spec/unit/util/ip_helper_spec.rb | 78 +-- 264 files changed, 3353 insertions(+), 3429 deletions(-) diff --git a/Gemfile b/Gemfile index d2b8c2a8..43d513e7 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ group :development do gem "chef", github: "chef/chef", branch: "master" gem "sigar", :platform => "ruby" - gem 'plist' + gem "plist" gem "chefstyle", "= 0.1.0" # gem 'pry-byebug' diff --git a/Rakefile b/Rakefile index 6be0c8eb..980e3135 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,12 @@ require "bundler/gem_tasks" -require 'date' -require 'ohai/version' +require "date" +require "ohai/version" begin - require 'rspec/core/rake_task' + require "rspec/core/rake_task" RSpec::Core::RakeTask.new do |t| - t.pattern = 'spec/**/*_spec.rb' + t.pattern = "spec/**/*_spec.rb" end rescue LoadError desc "rspec is not installed, this task is disabled" diff --git a/bin/ohai b/bin/ohai index d6ec07da..4bc6b066 100755 --- a/bin/ohai +++ b/bin/ohai @@ -19,9 +19,8 @@ # limitations under the License. # - begin - require 'rubygems' + require "rubygems" rescue LoadError # must be debian! ;) missing_rubygems = true @@ -29,8 +28,8 @@ end begin # if we're in a source code checkout, we want to run the code from that. # have to do this *after* rubygems is loaded. - $:.unshift File.expand_path('../../lib', __FILE__) - require 'ohai/application' + $:.unshift File.expand_path("../../lib", __FILE__) + require "ohai/application" rescue LoadError if missing_rubygems STDERR.puts "rubygems previously failed to load - is it installed?" diff --git a/lib/ohai.rb b/lib/ohai.rb index bf31dcc6..83724d97 100644 --- a/lib/ohai.rb +++ b/lib/ohai.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'ohai/version' -require 'ohai/config' -require 'ohai/system' -require 'ohai/exception' +require "ohai/version" +require "ohai/config" +require "ohai/system" +require "ohai/exception" diff --git a/lib/ohai/application.rb b/lib/ohai/application.rb index 7ecc22de..690ecae3 100644 --- a/lib/ohai/application.rb +++ b/lib/ohai/application.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'chef-config/path_helper' -require 'chef-config/workstation_config_loader' -require 'ohai' -require 'ohai/log' -require 'mixlib/cli' +require "chef-config/path_helper" +require "chef-config/workstation_config_loader" +require "ohai" +require "ohai/log" +require "mixlib/cli" class Ohai::Application include Mixlib::CLI @@ -62,7 +62,7 @@ class Ohai::Application :long => "--version", :description => "Show Ohai version", :boolean => true, - :proc => lambda {|v| puts "Ohai: #{::Ohai::VERSION}"}, + :proc => lambda { |v| puts "Ohai: #{::Ohai::VERSION}" }, :exit => 0 def initialize @@ -113,6 +113,7 @@ class Ohai::Application end private + def load_workstation_config config_loader = ChefConfig::WorkstationConfigLoader.new( config[:config_file], Ohai::Log diff --git a/lib/ohai/common/dmi.rb b/lib/ohai/common/dmi.rb index 4bdce5cb..6a483d3d 100644 --- a/lib/ohai/common/dmi.rb +++ b/lib/ohai/common/dmi.rb @@ -6,9 +6,9 @@ # 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. @@ -25,48 +25,48 @@ module Ohai # 128-255 are 'oem_data_[id]' # Everything else is 'unknown' IdToDescription = { - 0 => 'bios', - 1 => 'system', - 2 => 'base_board', - 3 => 'chassis', - 4 => 'processor', - 5 => 'memory_controller', - 6 => 'memory_module', - 7 => 'cache', - 8 => 'port_connector', - 9 => 'system_slots', - 10 => 'on_board_devices', - 11 => 'oem_strings', - 12 => 'system_configuration_options', - 13 => 'bios_language', - 14 => 'group_associations', - 15 => 'system_event_log', - 16 => 'physical_memory_array', - 17 => 'memory_device', - 18 => '32_bit_memory_error', - 19 => 'memory_array_mapped_address', - 20 => 'memory_device_mapped_address', - 21 => 'built_in_pointing_device', - 22 => 'portable_battery', - 23 => 'system_reset', - 24 => 'hardware_security', - 25 => 'system_power_controls', - 26 => 'voltage_probe', - 27 => 'cooling_device', - 28 => 'temperature_probe', - 29 => 'electrical_current_probe', - 30 => 'out_of_band_remote_access', - 31 => 'boot_integrity_services', - 32 => 'system_boot', - 33 => '64_bit_memory_error', - 34 => 'management_device', - 35 => 'management_device_component', - 36 => 'management_device_threshold_data', - 37 => 'memory_channel', - 38 => 'ipmi_device', - 39 => 'power_supply', - 126 => 'disabled_entries', - 127 => 'end_of_table_marker', + 0 => "bios", + 1 => "system", + 2 => "base_board", + 3 => "chassis", + 4 => "processor", + 5 => "memory_controller", + 6 => "memory_module", + 7 => "cache", + 8 => "port_connector", + 9 => "system_slots", + 10 => "on_board_devices", + 11 => "oem_strings", + 12 => "system_configuration_options", + 13 => "bios_language", + 14 => "group_associations", + 15 => "system_event_log", + 16 => "physical_memory_array", + 17 => "memory_device", + 18 => "32_bit_memory_error", + 19 => "memory_array_mapped_address", + 20 => "memory_device_mapped_address", + 21 => "built_in_pointing_device", + 22 => "portable_battery", + 23 => "system_reset", + 24 => "hardware_security", + 25 => "system_power_controls", + 26 => "voltage_probe", + 27 => "cooling_device", + 28 => "temperature_probe", + 29 => "electrical_current_probe", + 30 => "out_of_band_remote_access", + 31 => "boot_integrity_services", + 32 => "system_boot", + 33 => "64_bit_memory_error", + 34 => "management_device", + 35 => "management_device_component", + 36 => "management_device_threshold_data", + 37 => "memory_channel", + 38 => "ipmi_device", + 39 => "power_supply", + 126 => "disabled_entries", + 127 => "end_of_table_marker", } # list of IDs to collect, otherwise we generate pages of hashes about cache chip size and whatnot @@ -83,7 +83,7 @@ module Ohai id = DMI::IdToDescription[id] else Ohai::Log.debug("unrecognized header id; falling back to 'unknown'") - id = 'unknown' + id = "unknown" end rescue Ohai::Log.debug("failed to look up id #{id}, returning unchanged") @@ -95,17 +95,17 @@ module Ohai # for single occurrences of one type, copy to top level all fields and values # for multiple occurrences of same type, copy to top level all fields and values that are common to all records def convenience_keys(dmi) - dmi.each{ |type, records| + dmi.each { |type, records| in_common = Mash.new - next unless records.class.to_s == 'Mash' - next unless records.has_key?('all_records') - records[:all_records].each{ |record| - record.each{ |field, value| - next if value.class.to_s == 'Mash' - next if field.to_s == 'application_identifier' - next if field.to_s == 'size' - next if field.to_s == 'record_id' - translated = field.downcase.gsub(/[^a-z0-9]/, '_') + next unless records.class.to_s == "Mash" + next unless records.has_key?("all_records") + records[:all_records].each { |record| + record.each { |field, value| + next if value.class.to_s == "Mash" + next if field.to_s == "application_identifier" + next if field.to_s == "size" + next if field.to_s == "record_id" + translated = field.downcase.gsub(/[^a-z0-9]/, "_") value = value.strip if in_common.has_key?(translated) in_common[translated] = nil unless in_common[translated] == value @@ -114,7 +114,7 @@ module Ohai end } } - in_common.each{ |field, value| + in_common.each { |field, value| next if value == nil dmi[type][field] = value.strip } diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index c6996695..1ce5723f 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -17,10 +17,10 @@ # limitations under the License. # -require 'chef-config/config' -require 'ohai/exception' -require 'ohai/log' -require 'ohai/plugin_config' +require "chef-config/config" +require "ohai/exception" +require "ohai/log" +require "ohai/plugin_config" module Ohai Config = ChefConfig::Config @@ -30,16 +30,19 @@ module Ohai class Config # These methods need to be defined before they are used as config defaults, # otherwise they will get method_missing'd to nil. + private + def self.default_hints_path - [ ChefConfig::Config.platform_specific_path('/etc/chef/ohai/hints') ] + [ ChefConfig::Config.platform_specific_path("/etc/chef/ohai/hints") ] end def self.default_plugin_path - [ File.expand_path(File.join(File.dirname(__FILE__), 'plugins')) ] + [ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ] end public + # Copy deprecated configuration options into the ohai config context. def self.merge_deprecated_config [ :hints_path, :plugin_path ].each do |option| @@ -68,7 +71,7 @@ module Ohai :disabled_plugins, :log_level, :log_location, - :version + :version, ].each do |option| # https://docs.chef.io/config_rb_client.html#ohai-settings # hints_path and plugin_path are intentionally excluded here; warnings for @@ -100,6 +103,7 @@ module Ohai end private + def self.option_deprecated(option) <<-EOM.chomp!.gsub("\n", " ") Ohai::Config[:#{option}] is set. Ohai::Config[:#{option}] is deprecated and will @@ -119,6 +123,6 @@ EOM # Shortcut for Ohai::Config.ohai def self.config - Config::ohai + Config.ohai end end diff --git a/lib/ohai/dsl.rb b/lib/ohai/dsl.rb index e33d96b5..025f6be5 100644 --- a/lib/ohai/dsl.rb +++ b/lib/ohai/dsl.rb @@ -17,6 +17,6 @@ # limitations under the License. # -require 'ohai/dsl/plugin' -require 'ohai/dsl/plugin/versionvi' -require 'ohai/dsl/plugin/versionvii' +require "ohai/dsl/plugin" +require "ohai/dsl/plugin/versionvi" +require "ohai/dsl/plugin/versionvii" diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb index e2a0e5b8..53b5211e 100644 --- a/lib/ohai/dsl/plugin.rb +++ b/lib/ohai/dsl/plugin.rb @@ -18,10 +18,10 @@ # limitations under the License. # -require 'ohai/mixin/os' -require 'ohai/mixin/command' -require 'ohai/mixin/seconds_to_human' -require 'ohai/hints' +require "ohai/mixin/os" +require "ohai/mixin/command" +require "ohai/mixin/seconds_to_human" +require "ohai/hints" module Ohai @@ -171,7 +171,7 @@ module Ohai raise e rescue => e Ohai::Log.debug("Plugin #{self.name} threw #{e.inspect}") - e.backtrace.each { |line| Ohai::Log.debug( line )} + e.backtrace.each { |line| Ohai::Log.debug( line ) } end end diff --git a/lib/ohai/dsl/plugin/versionvi.rb b/lib/ohai/dsl/plugin/versionvi.rb index 11d9fdae..704581de 100644 --- a/lib/ohai/dsl/plugin/versionvi.rb +++ b/lib/ohai/dsl/plugin/versionvi.rb @@ -59,4 +59,3 @@ module Ohai end end end - diff --git a/lib/ohai/dsl/plugin/versionvii.rb b/lib/ohai/dsl/plugin/versionvii.rb index 741c6823..f129f828 100644 --- a/lib/ohai/dsl/plugin/versionvii.rb +++ b/lib/ohai/dsl/plugin/versionvii.rb @@ -112,6 +112,7 @@ module Ohai end private + def plugin_config @plugin_config ||= fetch_plugin_config end diff --git a/lib/ohai/hints.rb b/lib/ohai/hints.rb index 0ed9ae5c..20420856 100644 --- a/lib/ohai/hints.rb +++ b/lib/ohai/hints.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'ffi_yajl' +require "ffi_yajl" module Ohai module Hints diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb index 2381d06f..6680be90 100644 --- a/lib/ohai/loader.rb +++ b/lib/ohai/loader.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'chef-config/path_helper' -require 'ohai/log' -require 'ohai/mash' -require 'ohai/dsl' -require 'pathname' +require "chef-config/path_helper" +require "ohai/log" +require "ohai/mash" +require "ohai/dsl" +require "pathname" module Ohai @@ -95,7 +95,7 @@ module Ohai # If `plugin_dir_path` is given, and the file at `plugin_path` is a v6 # plugin, the 'relative path' of the plugin (used by `require_plugin()`) is # computed by finding the relative path from `plugin_dir_path` to `plugin_path` - def load_plugin_class(plugin_path, plugin_dir_path=nil) + def load_plugin_class(plugin_path, plugin_dir_path = nil) # Read the contents of the plugin to understand if it's a V6 or V7 plugin. contents = "" begin diff --git a/lib/ohai/log.rb b/lib/ohai/log.rb index 22dd39dd..c63f7abe 100644 --- a/lib/ohai/log.rb +++ b/lib/ohai/log.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'mixlib/log' +require "mixlib/log" module Ohai class Log diff --git a/lib/ohai/mash.rb b/lib/ohai/mash.rb index 368d806b..8dcf4b25 100644 --- a/lib/ohai/mash.rb +++ b/lib/ohai/mash.rb @@ -128,7 +128,7 @@ class Mash < Hash # # @return [Array] The values at each of the provided keys def values_at(*indices) - indices.collect {|key| self[convert_key(key)]} + indices.collect { |key| self[convert_key(key)] } end # @param hash The hash to merge with the mash. @@ -152,7 +152,7 @@ class Mash < Hash # { :one => 1, :two => 2, :three => 3 }.except(:one) # #=> { "two" => 2, "three" => 3 } def except(*keys) - super(*keys.map {|k| convert_key(k)}) + super(*keys.map { |k| convert_key(k) }) end # Used to provide the same interface as Hash. @@ -181,6 +181,7 @@ class Mash < Hash end protected + # @param key The key to convert. # # @param [Object] diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index d8e3252d..ded7c5f4 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'ohai/exception' -require 'ohai/config' -require 'ohai/log' -require 'stringio' -require 'tmpdir' -require 'fcntl' -require 'etc' -require 'mixlib/shellout' +require "ohai/exception" +require "ohai/config" +require "ohai/log" +require "stringio" +require "tmpdir" +require "fcntl" +require "etc" +require "mixlib/shellout" module Ohai module Mixin @@ -36,7 +36,7 @@ module Ohai module_function :shell_out - def run_command(args={}) + def run_command(args = {}) if args.has_key?(:creates) if File.exists?(args[:creates]) Ohai::Log.debug("Skipping #{args[:command]} - creates #{args[:creates]} exists.") @@ -123,19 +123,18 @@ module Ohai # The original appears in external/open4.rb in its unmodified form. # # Thanks Ara! - def popen4(cmd, args={}, &b) - - ## Disable garbage collection to work around possible bug in MRI + def popen4(cmd, args = {}, &b) + ## Disable garbage collection to work around possible bug in MRI # Ruby 1.8 suffers from intermittent segfaults believed to be due to GC while IO.select # See OHAI-330 / CHEF-2916 / CHEF-1305 - GC.disable - - # Waitlast - this is magic. - # - # Do we wait for the child process to die before we yield - # to the block, or after? That is the magic of waitlast. - # - # By default, we are waiting before we yield the block. + GC.disable + + # Waitlast - this is magic. + # + # Do we wait for the child process to die before we yield + # to the block, or after? That is the magic of waitlast. + # + # By default, we are waiting before we yield the block. args[:waitlast] ||= false args[:user] ||= nil @@ -148,9 +147,9 @@ module Ohai end args[:environment] ||= {} - # Default on C locale so parsing commands output can be done - # independently of the node's default locale. - # "LC_ALL" could be set to nil, in which case we also must ignore it. + # Default on C locale so parsing commands output can be done + # independently of the node's default locale. + # "LC_ALL" could be set to nil, in which case we also must ignore it. unless args[:environment].has_key?("LC_ALL") args[:environment]["LC_ALL"] = "C" end @@ -189,7 +188,7 @@ module Ohai Process.uid = args[:user] end - args[:environment].each do |key,value| + args[:environment].each do |key, value| ENV[key] = value end @@ -204,19 +203,19 @@ module Ohai else exec(cmd) end - raise 'forty-two' + raise "forty-two" rescue Exception => e Marshal.dump(e, ps.last) ps.last.flush end - ps.last.close unless (ps.last.closed?) + ps.last.close unless ps.last.closed? exit! } ensure $VERBOSE = verbose end - [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close} + [pw.first, pr.last, pe.last, ps.last].each { |fd| fd.close } begin e = Marshal.load ps.first @@ -325,15 +324,15 @@ module Ohai # have encoding methods. if "".respond_to?(:force_encoding) && defined?(Encoding) o.string.force_encoding(Encoding.default_external) - o.string.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?') + o.string.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?") e.string.force_encoding(Encoding.default_external) - e.string.encode!('UTF-8', :invalid => :replace, :undef => :replace, :replace => '?') + e.string.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?") end b[cid, pi[0], o, e] results.last end ensure - pi.each{|fd| fd.close unless fd.closed?} + pi.each { |fd| fd.close unless fd.closed? } end else [cid, pw.last, pr.first, pe.first] @@ -341,8 +340,8 @@ module Ohai rescue Errno::ENOENT raise Ohai::Exceptions::Exec, "command #{cmd} doesn't exist or is not in the PATH" ensure - # we disabled GC entering - GC.enable + # we disabled GC entering + GC.enable end module_function :popen4 diff --git a/lib/ohai/mixin/dmi_decode.rb b/lib/ohai/mixin/dmi_decode.rb index 1b3ba625..c8c4c5ac 100644 --- a/lib/ohai/mixin/dmi_decode.rb +++ b/lib/ohai/mixin/dmi_decode.rb @@ -23,23 +23,23 @@ module ::Ohai::Mixin::DmiDecode when /Manufacturer: Microsoft/ if dmi_data =~ /Product Name: Virtual Machine/ if dmi_data =~ /Version: (7.0|Hyper-V)/ - return 'hyperv' + return "hyperv" elsif dmi_data =~ /Version: (VS2005R2|6.0)/ - return 'virtualpc' + return "virtualpc" elsif dmi_data =~ /Version: 5.0/ - return 'virtualserver' + return "virtualserver" end end when /Manufacturer: VMware/ - return 'vmware' + return "vmware" when /Manufacturer: Xen/ - return 'xen' + return "xen" when /Product Name: VirtualBox/ - return 'vbox' + return "vbox" when /Product Name: OpenStack/ - return 'openstack' + return "openstack" when /Manufacturer: QEMU|Product Name: (KVM|RHEV)/ - return 'kvm' + return "kvm" end end return nil diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb index 4a100161..14a122d3 100644 --- a/lib/ohai/mixin/ec2_metadata.rb +++ b/lib/ohai/mixin/ec2_metadata.rb @@ -17,8 +17,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'net/http' -require 'socket' +require "net/http" +require "socket" module Ohai module Mixin @@ -41,15 +41,15 @@ module Ohai module Ec2Metadata EC2_METADATA_ADDR = "169.254.169.254" unless defined?(EC2_METADATA_ADDR) - EC2_SUPPORTED_VERSIONS = %w( 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15 + EC2_SUPPORTED_VERSIONS = %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12 - 2014-11-05 2014-02-25 ) + 2014-11-05 2014-02-25 } - EC2_ARRAY_VALUES = %w(security-groups) - EC2_ARRAY_DIR = %w(network/interfaces/macs) - EC2_JSON_DIR = %w(iam) + EC2_ARRAY_VALUES = %w{security-groups} + EC2_ARRAY_DIR = %w{network/interfaces/macs} + EC2_JSON_DIR = %w{iam} - def can_metadata_connect?(addr, port, timeout=2) + def can_metadata_connect?(addr, port, timeout = 2) t = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0) saddr = Socket.pack_sockaddr_in(port, addr) connected = false @@ -57,7 +57,7 @@ module Ohai begin t.connect_nonblock(saddr) rescue Errno::EINPROGRESS - r,w,e = IO::select(nil,[t],nil,timeout) + r, w, e = IO.select(nil, [t], nil, timeout) if !w.nil? connected = true else @@ -77,19 +77,19 @@ module Ohai def best_api_version response = http_client.get("/") - if response.code == '404' + if response.code == "404" Ohai::Log.debug("ec2 metadata mixin: Received HTTP 404 from metadata server while determining API version, assuming 'latest'") return "latest" - elsif response.code != '200' + elsif response.code != "200" raise "Unable to determine EC2 metadata version (returned #{response.code} response)" end # Note: Sorting the list of versions may have unintended consequences in # non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12. versions = response.body.split("\n") versions = response.body.split("\n").sort - until (versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)) do + until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last) pv = versions.pop - Ohai::Log.debug("ec2 metadata mixin: EC2 shows unsupported metadata version: #{pv}") unless pv == 'latest' + Ohai::Log.debug("ec2 metadata mixin: EC2 shows unsupported metadata version: #{pv}") unless pv == "latest" end Ohai::Log.debug("ec2 metadata mixin: EC2 metadata version: #{versions.last}") if versions.empty? @@ -99,7 +99,7 @@ module Ohai end def http_client - Net::HTTP.start(EC2_METADATA_ADDR).tap {|h| h.read_timeout = 600} + Net::HTTP.start(EC2_METADATA_ADDR).tap { |h| h.read_timeout = 600 } end # Get metadata for a given path and API version @@ -113,9 +113,9 @@ module Ohai path = "/#{api_version}/meta-data/#{id}" response = http_client.get(path) case response.code - when '200' + when "200" response.body - when '404' + when "404" Ohai::Log.debug("ec2 metadata mixin: Encountered 404 response retreiving EC2 metadata path: #{path} ; continuing.") nil else @@ -123,7 +123,7 @@ module Ohai end end - def fetch_metadata(id='', api_version=nil) + def fetch_metadata(id = "", api_version = nil) api_version ||= best_api_version return {} if api_version.nil? @@ -132,7 +132,7 @@ module Ohai if retrieved_metadata retrieved_metadata.split("\n").each do |o| key = expand_path("#{id}#{o}") - if key[-1..-1] != '/' + if key[-1..-1] != "/" metadata[metadata_key(key)] = if EC2_ARRAY_VALUES.include? key retr_meta = metadata_get(key, api_version) @@ -140,7 +140,7 @@ module Ohai else metadata_get(key, api_version) end - elsif not key.eql?(id) and not key.eql?('/') + elsif not key.eql?(id) and not key.eql?("/") name = key[0..-2] sym = metadata_key(name) if EC2_ARRAY_DIR.include?(name) @@ -148,7 +148,7 @@ module Ohai elsif EC2_JSON_DIR.include?(name) metadata[sym] = fetch_json_dir_metadata(key, api_version) else - fetch_metadata(key, api_version).each{|k,v| metadata[k] = v} + fetch_metadata(key, api_version).each { |k, v| metadata[k] = v } end end end @@ -162,10 +162,10 @@ module Ohai if retrieved_metadata retrieved_metadata.split("\n").each do |o| key = expand_path(o) - if key[-1..-1] != '/' + if key[-1..-1] != "/" retr_meta = metadata_get("#{id}#{key}", api_version) - metadata[metadata_key(key)] = retr_meta ? retr_meta : '' - elsif not key.eql?('/') + metadata[metadata_key(key)] = retr_meta ? retr_meta : "" + elsif not key.eql?("/") metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version) end end @@ -179,13 +179,13 @@ module Ohai if retrieved_metadata retrieved_metadata.split("\n").each do |o| key = expand_path(o) - if key[-1..-1] != '/' + if key[-1..-1] != "/" retr_meta = metadata_get("#{id}#{key}", api_version) - data = retr_meta ? retr_meta : '' + data = retr_meta ? retr_meta : "" json = StringIO.new(data) parser = FFI_Yajl::Parser.new metadata[metadata_key(key)] = parser.parse(json) - elsif not key.eql?('/') + elsif not key.eql?("/") metadata[key[0..-2]] = fetch_json_dir_metadata("#{id}#{key}", api_version) end end @@ -203,15 +203,15 @@ module Ohai private def expand_path(file_name) - path = file_name.gsub(/\=.*$/, '/') + path = file_name.gsub(/\=.*$/, "/") # ignore "./" and "../" - path.gsub(%r{/\.\.?(?:/|$)}, '/'). - sub(%r{^\.\.?(?:/|$)}, ''). - sub(%r{^$}, '/') + path.gsub(%r{/\.\.?(?:/|$)}, "/"). + sub(%r{^\.\.?(?:/|$)}, ""). + sub(%r{^$}, "/") end def metadata_key(key) - key.gsub(/\-|\//, '_') + key.gsub(/\-|\//, "_") end end diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb index accbb9a7..05127a5e 100644 --- a/lib/ohai/mixin/gce_metadata.rb +++ b/lib/ohai/mixin/gce_metadata.rb @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'net/http' -require 'socket' +require "net/http" +require "socket" module Ohai module Mixin @@ -25,7 +25,7 @@ module Ohai GCE_METADATA_ADDR = "metadata.google.internal." unless defined?(GCE_METADATA_ADDR) GCE_METADATA_URL = "/computeMetadata/v1beta1/?recursive=true" unless defined?(GCE_METADATA_URL) - def can_metadata_connect?(addr, port, timeout=2) + def can_metadata_connect?(addr, port, timeout = 2) t = Socket.new(Socket::Constants::AF_INET, Socket::Constants::SOCK_STREAM, 0) saddr = Socket.pack_sockaddr_in(port, addr) connected = false @@ -33,7 +33,7 @@ module Ohai begin t.connect_nonblock(saddr) rescue Errno::EINPROGRESS - r,w,e = IO::select(nil,[t],nil,timeout) + r, w, e = IO.select(nil, [t], nil, timeout) if !w.nil? connected = true else @@ -52,10 +52,10 @@ module Ohai end def http_client - Net::HTTP.start(GCE_METADATA_ADDR).tap {|h| h.read_timeout = 6} + Net::HTTP.start(GCE_METADATA_ADDR).tap { |h| h.read_timeout = 6 } end - def fetch_metadata(id='') + def fetch_metadata(id = "") uri = "#{GCE_METADATA_URL}/#{id}" response = http_client.get(uri) return nil unless response.code == "200" @@ -64,8 +64,8 @@ module Ohai data = StringIO.new(response.body) parser = FFI_Yajl::Parser.new parser.parse(data) - elsif has_trailing_slash?(id) or (id == '') - temp={} + elsif has_trailing_slash?(id) or (id == "") + temp = {} response.body.split("\n").each do |sub_attr| temp[sanitize_key(sub_attr)] = fetch_metadata("#{id}#{sub_attr}") end @@ -95,7 +95,7 @@ module Ohai end def sanitize_key(key) - key.gsub(/\-|\//, '_') + key.gsub(/\-|\//, "_") end end end diff --git a/lib/ohai/mixin/network_constants.rb b/lib/ohai/mixin/network_constants.rb index 6a529a14..ed53bb8b 100644 --- a/lib/ohai/mixin/network_constants.rb +++ b/lib/ohai/mixin/network_constants.rb @@ -22,7 +22,7 @@ module Ohai module NetworkConstants FAMILIES = { "inet" => "default", - "inet6" => "default_inet6" + "inet6" => "default_inet6", } # From sigar: include/sigar.h sigar_net_route_t diff --git a/lib/ohai/mixin/os.rb b/lib/ohai/mixin/os.rb index 8aa8f77c..83cdc34e 100644 --- a/lib/ohai/mixin/os.rb +++ b/lib/ohai/mixin/os.rb @@ -17,14 +17,14 @@ # limitations under the License. # -require 'rbconfig' +require "rbconfig" module Ohai module Mixin module OS def collect_os - case ::RbConfig::CONFIG['host_os'] + case ::RbConfig::CONFIG["host_os"] when /aix(.+)$/ return "aix" when /darwin(.+)$/ @@ -51,7 +51,7 @@ module Ohai # subsystems. return "windows" else - return ::RbConfig::CONFIG['host_os'] + return ::RbConfig::CONFIG["host_os"] end end diff --git a/lib/ohai/mixin/seconds_to_human.rb b/lib/ohai/mixin/seconds_to_human.rb index caeb4d8a..6d888970 100644 --- a/lib/ohai/mixin/seconds_to_human.rb +++ b/lib/ohai/mixin/seconds_to_human.rb @@ -44,5 +44,3 @@ module Ohai end end end - - diff --git a/lib/ohai/mixin/softlayer_metadata.rb b/lib/ohai/mixin/softlayer_metadata.rb index a7ee8511..f8568110 100644 --- a/lib/ohai/mixin/softlayer_metadata.rb +++ b/lib/ohai/mixin/softlayer_metadata.rb @@ -17,20 +17,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'net/https' -require 'uri' +require "net/https" +require "uri" # http://sldn.softlayer.com/reference/services/SoftLayer_Resource_Metadata module ::Ohai::Mixin::SoftlayerMetadata - SOFTLAYER_API_QUERY_URL = 'https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata' unless defined?(SOFTLAYER_API_QUERY_URL) + SOFTLAYER_API_QUERY_URL = "https://api.service.softlayer.com/rest/v3.1/SoftLayer_Resource_Metadata" unless defined?(SOFTLAYER_API_QUERY_URL) def fetch_metadata - metadata = { - 'public_fqdn' => fetch_metadata_item("getFullyQualifiedDomainName.txt"), - 'local_ipv4' => fetch_metadata_item("getPrimaryBackendIpAddress.txt"), - 'public_ipv4' => fetch_metadata_item("getPrimaryIpAddress.txt"), - 'region' => fetch_metadata_item("getDatacenter.txt"), - 'instance_id' => fetch_metadata_item("getId.txt") + metadata = { + "public_fqdn" => fetch_metadata_item("getFullyQualifiedDomainName.txt"), + "local_ipv4" => fetch_metadata_item("getPrimaryBackendIpAddress.txt"), + "public_ipv4" => fetch_metadata_item("getPrimaryIpAddress.txt"), + "region" => fetch_metadata_item("getDatacenter.txt"), + "instance_id" => fetch_metadata_item("getId.txt"), } end @@ -51,7 +51,7 @@ module ::Ohai::Mixin::SoftlayerMetadata net.use_ssl = true net.ca_file = ca_file_location res = net.get(u.request_uri) - if res.code.to_i.between?(200,299) + if res.code.to_i.between?(200, 299) res.body else ::Ohai::Log.error("Unable to fetch item #{full_url}: status (#{res.code}) body (#{res.body})") diff --git a/lib/ohai/mixin/string.rb b/lib/ohai/mixin/string.rb index 6f1e4da9..48830a36 100644 --- a/lib/ohai/mixin/string.rb +++ b/lib/ohai/mixin/string.rb @@ -23,7 +23,7 @@ class String # This should implement the same functionality as underscore method in # ActiveSupport::CoreExtensions::String::Inflections def wmi_underscore - self.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). - gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase + self.gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). + gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase end end diff --git a/lib/ohai/plugin_config.rb b/lib/ohai/plugin_config.rb index fe38c02c..b757af21 100644 --- a/lib/ohai/plugin_config.rb +++ b/lib/ohai/plugin_config.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'ohai/exception' +require "ohai/exception" module Ohai class PluginConfig < Hash diff --git a/lib/ohai/plugins/aix/cpu.rb b/lib/ohai/plugins/aix/cpu.rb index 26e047d2..f1e548b1 100644 --- a/lib/ohai/plugins/aix/cpu.rb +++ b/lib/ohai/plugins/aix/cpu.rb @@ -27,7 +27,7 @@ Ohai.plugin(:CPU) do cpu[:total] = shell_out("pmcycles -m").stdout.lines.length # The below is only relevent on an LPAR - if shell_out('uname -W').stdout.strip == "0" + if shell_out("uname -W").stdout.strip == "0" # At least one CPU will be available, but we'll wait to increment this later. cpu[:available] = 0 @@ -36,7 +36,7 @@ Ohai.plugin(:CPU) do #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html #on AIX number of cores and processors are considered same cpu[:real] = cpu[:cores] = cpudevs.length - cpudevs.each.with_index do |c,i| + cpudevs.each.with_index do |c, i| name, status, location = c.split index = i.to_s cpu[index] = Mash.new diff --git a/lib/ohai/plugins/aix/filesystem.rb b/lib/ohai/plugins/aix/filesystem.rb index 3569adcc..8f90921c 100644 --- a/lib/ohai/plugins/aix/filesystem.rb +++ b/lib/ohai/plugins/aix/filesystem.rb @@ -54,14 +54,14 @@ Ohai.plugin(:Filesystem) do oldie[key] ||= Mash.new oldie[key][:mount] = fields[1] oldie[key][:fs_type] = fields[2] - oldie[key][:mount_options] = fields[6].split(',') + oldie[key][:mount_options] = fields[6].split(",") # entries occupying the 'Node' column parsed here else key = fields[0] + ":" + fields[1] oldie[key] ||= Mash.new oldie[key][:mount] = fields[1] oldie[key][:fs_type] = fields[3] - oldie[key][:mount_options] = fields[7].split(',') + oldie[key][:mount_options] = fields[7].split(",") end end oldie diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb index 50b33408..40630110 100644 --- a/lib/ohai/plugins/aix/memory.rb +++ b/lib/ohai/plugins/aix/memory.rb @@ -30,7 +30,7 @@ Ohai.plugin(:Memory) do memory[:free] = "#{free_in_mb.to_i * 1024}kB" swapinfo = shell_out("swap -s").stdout.split #returns swap info in 4K blocks - memory[:swap]['total'] = "#{(swapinfo[2].to_i) * 4}kB" - memory[:swap]['free'] = "#{(swapinfo[10].to_i) * 4}kB" + memory[:swap]["total"] = "#{(swapinfo[2].to_i) * 4}kB" + memory[:swap]["free"] = "#{(swapinfo[10].to_i) * 4}kB" end end diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb index f576e1fe..292b45c6 100644 --- a/lib/ohai/plugins/aix/network.rb +++ b/lib/ohai/plugins/aix/network.rb @@ -19,7 +19,7 @@ # Ohai.plugin(:Network) do - require 'ipaddr' + require "ipaddr" provides "network", "counters/network", "macaddress" @@ -27,7 +27,7 @@ Ohai.plugin(:Network) do def hex_to_dec_netmask(netmask) # example '0xffff0000' -> '255.255.0.0' dec = netmask[2..3].to_i(16).to_s(10) - [4,6,8].each { |n| dec = dec + "." + netmask[n..n+1].to_i(16).to_s(10) } + [4, 6, 8].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) } dec end @@ -53,7 +53,7 @@ Ohai.plugin(:Network) do # :default_interface, :default_gateway - route -n get 0 so = shell_out("netstat -rn |grep default") so.stdout.lines.each do |line| - items = line.split(' ') + items = line.split(" ") if items[0] == "default" network[:default_gateway] = items[1] network[:default_interface] = items[5] @@ -68,12 +68,12 @@ Ohai.plugin(:Network) do interface = splat[0] line = splat[1..-1][0] iface[interface] = Mash.new - iface[interface][:state] = (line.include?("/ - iface[interface][:flags] = $1.split(',') + iface[interface][:flags] = $1.split(",") iface[interface][:metric] = $1 if lin =~ /metric\s(\S+)/ else # We have key value pairs. @@ -103,9 +103,9 @@ Ohai.plugin(:Network) do else # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1" properties = lin.split - n = properties.length/2 - 1 + n = properties.length / 2 - 1 (0..n).each do |i| - iface[interface][properties[i*2]] = properties[(i*2+1)] + iface[interface][properties[i * 2]] = properties[(i * 2 + 1)] end end end @@ -120,7 +120,7 @@ Ohai.plugin(:Network) do macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0 end end - end #ifconfig stdout + end #ifconfig stdout # Query routes information %w{inet inet6}.each do |family| @@ -130,7 +130,7 @@ Ohai.plugin(:Network) do interface = $6 iface[interface][:routes] = Array.new unless iface[interface][:routes] iface[interface][:routes] << Mash.new( :destination => $1, :family => family, - :via => $2, :flags => $3) + :via => $2, :flags => $3) end end end @@ -151,4 +151,3 @@ Ohai.plugin(:Network) do network["interfaces"] = iface end end - diff --git a/lib/ohai/plugins/aix/os.rb b/lib/ohai/plugins/aix/os.rb index cdf1a0aa..ebbe760d 100644 --- a/lib/ohai/plugins/aix/os.rb +++ b/lib/ohai/plugins/aix/os.rb @@ -17,11 +17,11 @@ # limitations under the License. # -require 'ohai/mixin/os' +require "ohai/mixin/os" Ohai.plugin(:OS) do provides "os", "os_version" - depends 'kernel' + depends "kernel" collect_data(:aix) do os collect_os diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb index d0bf5d56..ce463753 100644 --- a/lib/ohai/plugins/aix/uptime.rb +++ b/lib/ohai/plugins/aix/uptime.rb @@ -21,14 +21,14 @@ Ohai.plugin(:Uptime) do provides "uptime", "uptime_seconds" collect_data(:aix) do - require 'date' + require "date" # Example output: # $ who -b # . system boot Jul 9 17:51 - so = shell_out('who -b') + so = shell_out("who -b") so.stdout.lines.each do |line| if line =~ /.* boot (.+)/ - uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime('%s').to_i + uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime("%s").to_i uptime seconds_to_human(uptime_seconds) break end diff --git a/lib/ohai/plugins/aix/virtualization.rb b/lib/ohai/plugins/aix/virtualization.rb index 0ffdb435..fdce73ef 100644 --- a/lib/ohai/plugins/aix/virtualization.rb +++ b/lib/ohai/plugins/aix/virtualization.rb @@ -56,63 +56,63 @@ Ohai.plugin(:Virtualization) do sections.each do |line| case title - when 'network' + when "network" next if line =~ /^Interface|^---/ splat = line.strip.split key = splat[0].downcase value = { - 'address' => splat[1], - 'netmask' => splat[2], - 'broadcast' => splat[3], + "address" => splat[1], + "netmask" => splat[2], + "broadcast" => splat[3], } wpars[wpar_name][title][key] = value - when 'user-specified routes' + when "user-specified routes" next if line =~ /^Type|^---/ splat = line.strip.split key = splat[2].downcase value = { - 'destination' => splat[0], - 'gateway' => splat[1], + "destination" => splat[0], + "gateway" => splat[1], } wpars[wpar_name][title][key] = value - when 'file systems' + when "file systems" next if line =~ /^MountPoint|^---/ splat = line.strip.split key = splat[1].downcase value = { - 'mountpoint' => splat[0], - 'device' => splat[1], - 'vfs' => splat[2], - 'options' => splat[3].split(','), + "mountpoint" => splat[0], + "device" => splat[1], + "vfs" => splat[2], + "options" => splat[3].split(","), } wpars[wpar_name][title][key] = value - when 'security settings' - privileges ||= '' - wpars[wpar_name][title]['Privileges'] ||= [] + when "security settings" + privileges ||= "" + wpars[wpar_name][title]["Privileges"] ||= [] if line =~ /^Privileges/ - privileges << line.split(':')[1].strip + privileges << line.split(":")[1].strip else privileges << line.strip end - wpars[wpar_name][title]['Privileges'] += privileges.split(',') - when 'device exports' + wpars[wpar_name][title]["Privileges"] += privileges.split(",") + when "device exports" next if line =~ /^Name|^---/ splat = line.strip.split key = splat[0].downcase value = { - 'type' => splat[1], - 'status' => splat[2], + "type" => splat[1], + "status" => splat[2], } wpars[wpar_name][title][key] = value else # key-value pairs are handled here # such as GENERAL and RESOURCE- # CONTROL - splat = line.strip.split(':') + splat = line.strip.split(":") key = splat[0].downcase - value = splat[1..-1].join(', ').strip + value = splat[1..-1].join(", ").strip value = value.empty? ? nil : value case value when "yes" @@ -136,7 +136,7 @@ Ohai.plugin(:Virtualization) do top_level.each do |attribute| evalstr = "wpars['#{wpar_name}']" - breadcrumb = attribute.split('.') + breadcrumb = attribute.split(".") breadcrumb.each do |node| evalstr << "[\'#{node}\']" end diff --git a/lib/ohai/plugins/azure.rb b/lib/ohai/plugins/azure.rb index 852bcd94..52fe1d9a 100644 --- a/lib/ohai/plugins/azure.rb +++ b/lib/ohai/plugins/azure.rb @@ -22,11 +22,11 @@ Ohai.plugin(:Azure) do # The project is located at https://github.com/chef/knife-azure # Please see the lib/chef/knife/azure_server_create.rb file in that # project for details - azure_metadata_from_hints = hint?('azure') + azure_metadata_from_hints = hint?("azure") if azure_metadata_from_hints Ohai::Log.debug("azure plugin: azure_metadata_from_hints is present.") azure Mash.new - azure_metadata_from_hints.each {|k, v| azure[k] = v } + azure_metadata_from_hints.each { |k, v| azure[k] = v } elsif looks_like_azure? Ohai::Log.debug("azure plugin: No hints present, but system appears to be on azure.") azure Mash.new @@ -39,10 +39,10 @@ Ohai.plugin(:Azure) do # check for either the waagent or the unknown-245 DHCP option that Azure uses # http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/ def looks_like_azure? - if File.exist?('/usr/sbin/waagent') || Dir.exist?('C:\WindowsAzure') + if File.exist?("/usr/sbin/waagent") || Dir.exist?('C:\WindowsAzure') Ohai::Log.debug("azure plugin: Found waagent used by MS Azure.") return true - elsif File.exist?('/var/lib/dhcp/dhclient.eth0.leases') + elsif File.exist?("/var/lib/dhcp/dhclient.eth0.leases") File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line| if line =~ /unknown-245/ Ohai::Log.debug("azure plugin: Found unknown-245 DHCP option used by MS Azure.") diff --git a/lib/ohai/plugins/bsd/virtualization.rb b/lib/ohai/plugins/bsd/virtualization.rb index 518d664d..c8bfe359 100644 --- a/lib/ohai/plugins/bsd/virtualization.rb +++ b/lib/ohai/plugins/bsd/virtualization.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'ohai/mixin/dmi_decode' +require "ohai/mixin/dmi_decode" include Ohai::Mixin::DmiDecode Ohai.plugin(:Virtualization) do - provides 'virtualization' + provides "virtualization" collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do @@ -33,14 +33,14 @@ Ohai.plugin(:Virtualization) do if so.stdout.split($/)[0].to_i == 1 virtualization[:system] = "jail" virtualization[:role] = "guest" - virtualization[:systems][:jail] = 'guest' + virtualization[:systems][:jail] = "guest" end - so = shell_out('jls -n') - if (so.stdout || '').lines.count >= 1 - virtualization[:system] = 'jail' - virtualization[:role] = 'host' - virtualization[:systems][:jail] = 'host' + so = shell_out("jls -n") + if (so.stdout || "").lines.count >= 1 + virtualization[:system] = "jail" + virtualization[:role] = "host" + virtualization[:systems][:jail] = "host" end # detect from modules @@ -48,32 +48,32 @@ Ohai.plugin(:Virtualization) do so.stdout.lines do |line| case line when /vboxdrv/ - virtualization[:system] = 'vbox' - virtualization[:role] = 'host' - virtualization[:systems][:vbox] = 'host' + virtualization[:system] = "vbox" + virtualization[:role] = "host" + virtualization[:systems][:vbox] = "host" when /vboxguest/ - virtualization[:system] = 'vbox' - virtualization[:role] = 'guest' - virtualization[:systems][:vbox] = 'guest' + virtualization[:system] = "vbox" + virtualization[:role] = "guest" + virtualization[:systems][:vbox] = "guest" end end # Detect KVM/QEMU from cpu, report as KVM # hw.model: QEMU Virtual CPU version 0.9.1 - so = shell_out('sysctl -n hw.model') + so = shell_out("sysctl -n hw.model") if so.stdout.split($/)[0] =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/ - virtualization[:system] = 'kvm' - virtualization[:role] = 'guest' - virtualization[:systems][:kvm] = 'guest' + virtualization[:system] = "kvm" + virtualization[:role] = "guest" + virtualization[:systems][:kvm] = "guest" end # parse dmidecode to discover various virtualization guests - if File.exist?('/usr/local/sbin/dmidecode') || File.exist?('/usr/pkg/sbin/dmidecode') - guest = guest_from_dmi(shell_out('dmidecode').stdout) + if File.exist?("/usr/local/sbin/dmidecode") || File.exist?("/usr/pkg/sbin/dmidecode") + guest = guest_from_dmi(shell_out("dmidecode").stdout) if guest virtualization[:system] = guest - virtualization[:role] = 'guest' - virtualization[:systems][guest.to_sym] = 'guest' + virtualization[:role] = "guest" + virtualization[:systems][guest.to_sym] = "guest" end end end diff --git a/lib/ohai/plugins/c.rb b/lib/ohai/plugins/c.rb index fdf798d0..8cea4d0c 100644 --- a/lib/ohai/plugins/c.rb +++ b/lib/ohai/plugins/c.rb @@ -6,9 +6,9 @@ # 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. @@ -16,7 +16,7 @@ # limitations under the License. # -require 'rbconfig' +require "rbconfig" Ohai.plugin(:C) do provides "languages/c" diff --git a/lib/ohai/plugins/chef.rb b/lib/ohai/plugins/chef.rb index 49052a5f..211a320e 100644 --- a/lib/ohai/plugins/chef.rb +++ b/lib/ohai/plugins/chef.rb @@ -21,7 +21,7 @@ Ohai.plugin(:Chef) do collect_data do begin - require 'chef/version' + require "chef/version" rescue Gem::LoadError # this catches when you've done a major version bump of ohai, but # your chef gem is incompatible, so we can't load it in the same VM diff --git a/lib/ohai/plugins/cloud.rb b/lib/ohai/plugins/cloud.rb index 301193c9..23084631 100644 --- a/lib/ohai/plugins/cloud.rb +++ b/lib/ohai/plugins/cloud.rb @@ -52,22 +52,22 @@ Ohai.plugin(:Cloud) do cloud[:public_ipv4] = [] cloud[:local_ipv4] = [] - public_ips = gce['instance']["networkInterfaces"].collect do |interface| - if interface.has_key?('accessConfigs') - interface['accessConfigs'].collect{|ac| ac['externalIp']} + public_ips = gce["instance"]["networkInterfaces"].collect do |interface| + if interface.has_key?("accessConfigs") + interface["accessConfigs"].collect { |ac| ac["externalIp"] } end end.flatten.compact - private_ips = gce['instance']["networkInterfaces"].collect do |interface| - interface['ip'] + private_ips = gce["instance"]["networkInterfaces"].collect do |interface| + interface["ip"] end.compact cloud[:public_ips] += public_ips cloud[:private_ips] += private_ips - cloud[:public_ipv4] += public_ips + cloud[:public_ipv4] += public_ips cloud[:public_hostname] = nil cloud[:local_ipv4] += private_ips - cloud[:local_hostname] = gce['instance']['hostname'] + cloud[:local_hostname] = gce["instance"]["hostname"] cloud[:provider] = "gce" end @@ -86,12 +86,12 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with ec2 values def get_ec2_values - cloud[:public_ips] << ec2['public_ipv4'] - cloud[:private_ips] << ec2['local_ipv4'] - cloud[:public_ipv4] = ec2['public_ipv4'] - cloud[:public_hostname] = ec2['public_hostname'] - cloud[:local_ipv4] = ec2['local_ipv4'] - cloud[:local_hostname] = ec2['local_hostname'] + cloud[:public_ips] << ec2["public_ipv4"] + cloud[:private_ips] << ec2["local_ipv4"] + cloud[:public_ipv4] = ec2["public_ipv4"] + cloud[:public_hostname] = ec2["public_hostname"] + cloud[:local_ipv4] = ec2["local_ipv4"] + cloud[:local_hostname] = ec2["local_hostname"] cloud[:provider] = "ec2" end @@ -110,14 +110,14 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with rackspace values def get_rackspace_values - cloud[:public_ips] << rackspace['public_ipv4'] if rackspace['public_ipv4'] - cloud[:private_ips] << rackspace['local_ipv4'] if rackspace['local_ipv4'] - cloud[:public_ipv4] = rackspace['public_ipv4'] - cloud[:public_ipv6] = rackspace['public_ipv6'] - cloud[:public_hostname] = rackspace['public_hostname'] - cloud[:local_ipv4] = rackspace['local_ipv4'] - cloud[:local_ipv6] = rackspace['local_ipv6'] - cloud[:local_hostname] = rackspace['local_hostname'] + cloud[:public_ips] << rackspace["public_ipv4"] if rackspace["public_ipv4"] + cloud[:private_ips] << rackspace["local_ipv4"] if rackspace["local_ipv4"] + cloud[:public_ipv4] = rackspace["public_ipv4"] + cloud[:public_ipv6] = rackspace["public_ipv6"] + cloud[:public_hostname] = rackspace["public_hostname"] + cloud[:local_ipv4] = rackspace["local_ipv4"] + cloud[:local_ipv6] = rackspace["local_ipv6"] + cloud[:local_hostname] = rackspace["local_hostname"] cloud[:provider] = "rackspace" end @@ -136,12 +136,12 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with linode values def get_linode_values - cloud[:public_ips] << linode['public_ip'] - cloud[:private_ips] << linode['private_ip'] - cloud[:public_ipv4] = linode['public_ipv4'] - cloud[:public_hostname] = linode['public_hostname'] - cloud[:local_ipv4] = linode['local_ipv4'] - cloud[:local_hostname] = linode['local_hostname'] + cloud[:public_ips] << linode["public_ip"] + cloud[:private_ips] << linode["private_ip"] + cloud[:public_ipv4] = linode["public_ipv4"] + cloud[:public_hostname] = linode["public_hostname"] + cloud[:local_ipv4] = linode["local_ipv4"] + cloud[:local_hostname] = linode["local_hostname"] cloud[:provider] = "linode" end @@ -159,12 +159,12 @@ Ohai.plugin(:Cloud) do end def get_eucalyptus_values - cloud[:public_ips] << eucalyptus['public_ipv4'] - cloud[:private_ips] << eucalyptus['local_ipv4'] - cloud[:public_ipv4] = eucalyptus['public_ipv4'] - cloud[:public_hostname] = eucalyptus['public_hostname'] - cloud[:local_ipv4] = eucalyptus['local_ipv4'] - cloud[:local_hostname] = eucalyptus['local_hostname'] + cloud[:public_ips] << eucalyptus["public_ipv4"] + cloud[:private_ips] << eucalyptus["local_ipv4"] + cloud[:public_ipv4] = eucalyptus["public_ipv4"] + cloud[:public_hostname] = eucalyptus["public_hostname"] + cloud[:local_ipv4] = eucalyptus["local_ipv4"] + cloud[:local_hostname] = eucalyptus["local_hostname"] cloud[:provider] = "eucalyptus" end @@ -183,13 +183,13 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with openstack values def get_openstack_values - cloud[:public_ips] << openstack['public_ipv4'] - cloud[:private_ips] << openstack['local_ipv4'] - cloud[:public_ipv4] = openstack['public_ipv4'] - cloud[:public_hostname] = openstack['public_hostname'] - cloud[:local_ipv4] = openstack['local_ipv4'] - cloud[:local_hostname] = openstack['local_hostname'] - cloud[:provider] = openstack['provider'] + cloud[:public_ips] << openstack["public_ipv4"] + cloud[:private_ips] << openstack["local_ipv4"] + cloud[:public_ipv4] = openstack["public_ipv4"] + cloud[:public_hostname] = openstack["public_hostname"] + cloud[:local_ipv4] = openstack["local_ipv4"] + cloud[:local_hostname] = openstack["local_hostname"] + cloud[:provider] = openstack["provider"] end # ---------------------------------------- @@ -208,12 +208,12 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with azure values def get_azure_values cloud[:vm_name] = azure["vm_name"] - cloud[:public_ips] << azure['public_ip'] - cloud[:public_ipv4] = azure['public_ip'] - cloud[:public_fqdn] = azure['public_fqdn'] - cloud[:public_hostname] = azure['public_fqdn'] - cloud[:public_ssh_port] = azure['public_ssh_port'] if azure['public_ssh_port'] - cloud[:public_winrm_port] = azure['public_winrm_port'] if azure['public_winrm_port'] + cloud[:public_ips] << azure["public_ip"] + cloud[:public_ipv4] = azure["public_ip"] + cloud[:public_fqdn] = azure["public_fqdn"] + cloud[:public_hostname] = azure["public_fqdn"] + cloud[:public_ssh_port] = azure["public_ssh_port"] if azure["public_ssh_port"] + cloud[:public_winrm_port] = azure["public_winrm_port"] if azure["public_winrm_port"] cloud[:provider] = "azure" end @@ -232,17 +232,17 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with linode values def get_digital_ocean_values - public_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'public'} - private_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'private'} - public_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'public'} - private_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'private'} - cloud[:public_ips].concat public_ipv4+public_ipv6 - cloud[:private_ips].concat private_ipv4+private_ipv6 + public_ipv4 = digital_ocean["networks"]["v4"].select { |address| address["type"] == "public" } + private_ipv4 = digital_ocean["networks"]["v4"].select { |address| address["type"] == "private" } + public_ipv6 = digital_ocean["networks"]["v6"].select { |address| address["type"] == "public" } + private_ipv6 = digital_ocean["networks"]["v6"].select { |address| address["type"] == "private" } + cloud[:public_ips].concat public_ipv4 + public_ipv6 + cloud[:private_ips].concat private_ipv4 + private_ipv6 cloud[:public_ipv4] = public_ipv4.first cloud[:public_ipv6] = public_ipv6.first cloud[:local_ipv4] = private_ipv4.first cloud[:local_ipv6] = private_ipv6.first - cloud[:public_hostname] = digital_ocean['name'] + cloud[:public_hostname] = digital_ocean["name"] cloud[:provider] = "digital_ocean" end @@ -261,15 +261,14 @@ Ohai.plugin(:Cloud) do # Fill cloud hash with softlayer values def get_softlayer_values - cloud[:public_ipv4] = softlayer['public_ipv4'] - cloud[:local_ipv4] = softlayer['local_ipv4'] - cloud[:public_ips] << softlayer['public_ipv4'] if softlayer['public_ipv4'] - cloud[:private_ips] << softlayer['local_ipv4'] if softlayer['local_ipv4'] - cloud[:public_hostname] = softlayer['public_fqdn'] - cloud[:provider] = 'softlayer' + cloud[:public_ipv4] = softlayer["public_ipv4"] + cloud[:local_ipv4] = softlayer["local_ipv4"] + cloud[:public_ips] << softlayer["public_ipv4"] if softlayer["public_ipv4"] + cloud[:private_ips] << softlayer["local_ipv4"] if softlayer["local_ipv4"] + cloud[:public_hostname] = softlayer["public_fqdn"] + cloud[:provider] = "softlayer" end - collect_data do # setup gce cloud if on_gce? diff --git a/lib/ohai/plugins/cloud_v2.rb b/lib/ohai/plugins/cloud_v2.rb index ceee89a3..7c3f3b1a 100644 --- a/lib/ohai/plugins/cloud_v2.rb +++ b/lib/ohai/plugins/cloud_v2.rb @@ -113,7 +113,6 @@ Ohai.plugin(:CloudV2) do end end - #--------------------------------------- # Google Compute Engine (gce) #-------------------------------------- @@ -123,19 +122,19 @@ Ohai.plugin(:CloudV2) do end def get_gce_values - public_ips = gce['instance']['networkInterfaces'].collect do |interface| - if interface.has_key?('accessConfigs') - interface['accessConfigs'].collect{|ac| ac['externalIp'] unless ac['externalIp'] == ''} + public_ips = gce["instance"]["networkInterfaces"].collect do |interface| + if interface.has_key?("accessConfigs") + interface["accessConfigs"].collect { |ac| ac["externalIp"] unless ac["externalIp"] == "" } end end.flatten.compact - private_ips = gce['instance']['networkInterfaces'].collect do |interface| - interface['ip'] + private_ips = gce["instance"]["networkInterfaces"].collect do |interface| + interface["ip"] end.compact - public_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) } - private_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) } - @cloud_attr_obj.local_hostname = gce['instance']['hostname'] + public_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :public) } + private_ips.each { |ipaddr| @cloud_attr_obj.add_ipv4_addr(ipaddr, :private) } + @cloud_attr_obj.local_hostname = gce["instance"]["hostname"] @cloud_attr_obj.provider = "gce" end @@ -154,10 +153,10 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with ec2 values def get_ec2_values - @cloud_attr_obj.add_ipv4_addr(ec2['public_ipv4'], :public) - @cloud_attr_obj.add_ipv4_addr(ec2['local_ipv4'], :private) - @cloud_attr_obj.public_hostname = ec2['public_hostname'] - @cloud_attr_obj.local_hostname = ec2['local_hostname'] + @cloud_attr_obj.add_ipv4_addr(ec2["public_ipv4"], :public) + @cloud_attr_obj.add_ipv4_addr(ec2["local_ipv4"], :private) + @cloud_attr_obj.public_hostname = ec2["public_hostname"] + @cloud_attr_obj.local_hostname = ec2["local_hostname"] @cloud_attr_obj.provider = "ec2" end @@ -176,12 +175,12 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with rackspace values def get_rackspace_values - @cloud_attr_obj.add_ipv4_addr(rackspace['public_ipv4'], :public) - @cloud_attr_obj.add_ipv4_addr(rackspace['local_ipv4'], :private) - @cloud_attr_obj.add_ipv6_addr(rackspace['public_ipv6'], :public) - @cloud_attr_obj.add_ipv6_addr(rackspace['local_ipv6'], :private) - @cloud_attr_obj.public_hostname = rackspace['public_hostname'] - @cloud_attr_obj.local_hostname = rackspace['local_hostname'] + @cloud_attr_obj.add_ipv4_addr(rackspace["public_ipv4"], :public) + @cloud_attr_obj.add_ipv4_addr(rackspace["local_ipv4"], :private) + @cloud_attr_obj.add_ipv6_addr(rackspace["public_ipv6"], :public) + @cloud_attr_obj.add_ipv6_addr(rackspace["local_ipv6"], :private) + @cloud_attr_obj.public_hostname = rackspace["public_hostname"] + @cloud_attr_obj.local_hostname = rackspace["local_hostname"] @cloud_attr_obj.provider = "rackspace" end @@ -200,10 +199,10 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with linode values def get_linode_values - @cloud_attr_obj.add_ipv4_addr(linode['public_ip'], :public) - @cloud_attr_obj.add_ipv4_addr(linode['private_ip'], :private) - @cloud_attr_obj.public_hostname = linode['public_hostname'] - @cloud_attr_obj.local_hostname = linode['local_hostname'] + @cloud_attr_obj.add_ipv4_addr(linode["public_ip"], :public) + @cloud_attr_obj.add_ipv4_addr(linode["private_ip"], :private) + @cloud_attr_obj.public_hostname = linode["public_hostname"] + @cloud_attr_obj.local_hostname = linode["local_hostname"] @cloud_attr_obj.provider = "linode" end @@ -221,10 +220,10 @@ Ohai.plugin(:CloudV2) do end def get_eucalyptus_values - @cloud_attr_obj.add_ipv4_addr(eucalyptus['public_ipv4'], :public) - @cloud_attr_obj.add_ipv4_addr(eucalyptus['local_ipv4'], :private) - @cloud_attr_obj.public_hostname = eucalyptus['public_hostname'] - @cloud_attr_obj.local_hostname = eucalyptus['local_hostname'] + @cloud_attr_obj.add_ipv4_addr(eucalyptus["public_ipv4"], :public) + @cloud_attr_obj.add_ipv4_addr(eucalyptus["local_ipv4"], :private) + @cloud_attr_obj.public_hostname = eucalyptus["public_hostname"] + @cloud_attr_obj.local_hostname = eucalyptus["local_hostname"] @cloud_attr_obj.provider = "eucalyptus" end @@ -243,10 +242,10 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with openstack values def get_openstack_values - @cloud_attr_obj.add_ipv4_addr(openstack['public_ipv4'], :public) - @cloud_attr_obj.add_ipv4_addr(openstack['local_ipv4'], :private) - @cloud_attr_obj.public_hostname = openstack['public_hostname'] - @cloud_attr_obj.local_hostname = openstack['local_hostname'] + @cloud_attr_obj.add_ipv4_addr(openstack["public_ipv4"], :public) + @cloud_attr_obj.add_ipv4_addr(openstack["local_ipv4"], :private) + @cloud_attr_obj.public_hostname = openstack["public_hostname"] + @cloud_attr_obj.local_hostname = openstack["local_hostname"] @cloud_attr_obj.provider = "openstack" end @@ -265,13 +264,12 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with azure values def get_azure_values - @cloud_attr_obj.add_ipv4_addr(azure['public_ip'], :public) - @cloud_attr_obj.add_ipv4_addr(azure['private_ip'], :private) - @cloud_attr_obj.public_hostname = azure['public_fqdn'] + @cloud_attr_obj.add_ipv4_addr(azure["public_ip"], :public) + @cloud_attr_obj.add_ipv4_addr(azure["private_ip"], :private) + @cloud_attr_obj.public_hostname = azure["public_fqdn"] @cloud_attr_obj.provider = "azure" end - # ---------------------------------------- # digital_ocean # ---------------------------------------- @@ -287,13 +285,13 @@ Ohai.plugin(:CloudV2) do # Fill cloud hash with digital_ocean values def get_digital_ocean_values - digital_ocean['networks'].each do |network, addresses| - type = network == 'v4' ? 'ipv4' : 'ipv6' + digital_ocean["networks"].each do |network, addresses| + type = network == "v4" ? "ipv4" : "ipv6" addresses.each do |address| - @cloud_attr_obj.send("add_#{type}_addr", address['ip_address'], address['type'].to_sym) + @cloud_attr_obj.send("add_#{type}_addr", address["ip_address"], address["type"].to_sym) end end - @cloud_attr_obj.public_hostname = digital_ocean['name'] + @cloud_attr_obj.public_hostname = digital_ocean["name"] @cloud_attr_obj.provider = "digital_ocean" end diff --git a/lib/ohai/plugins/darwin/cpu.rb b/lib/ohai/plugins/darwin/cpu.rb index 4e218921..baa72836 100644 --- a/lib/ohai/plugins/darwin/cpu.rb +++ b/lib/ohai/plugins/darwin/cpu.rb @@ -41,6 +41,6 @@ Ohai.plugin(:CPU) do so = shell_out("sysctl -n machdep.cpu.stepping") cpu[:stepping] = so.stdout.to_i so = shell_out("sysctl -n machdep.cpu.features") - cpu[:flags] = so.stdout.downcase.split(' ') + cpu[:flags] = so.stdout.downcase.split(" ") end end diff --git a/lib/ohai/plugins/darwin/filesystem2.rb b/lib/ohai/plugins/darwin/filesystem2.rb index 25b9009a..45b41e18 100644 --- a/lib/ohai/plugins/darwin/filesystem2.rb +++ b/lib/ohai/plugins/darwin/filesystem2.rb @@ -26,7 +26,7 @@ Ohai.plugin(:Filesystem2) do fs.each_value do |entry| view[entry[:device]] = Mash.new unless view[entry[:device]] entry.each do |key, val| - next if ['device', 'mount'].include?(key) + next if %w{device mount}.include?(key) view[entry[:device]][key] = val end if entry[:mount] @@ -43,7 +43,7 @@ Ohai.plugin(:Filesystem2) do next unless entry[:mount] view[entry[:mount]] = Mash.new unless view[entry[:mount]] entry.each do |key, val| - next if ['mount', 'device'].include?(key) + next if %w{mount device}.include?(key) view[entry[:mount]][key] = val end if entry[:device] @@ -98,9 +98,9 @@ Ohai.plugin(:Filesystem2) do by_mountpoint = generate_mountpoint_view(fs) fs2 = Mash.new - fs2['by_device'] = by_device - fs2['by_mountpoint'] = by_mountpoint - fs2['by_pair'] = by_pair + fs2["by_device"] = by_device + fs2["by_mountpoint"] = by_mountpoint + fs2["by_pair"] = by_pair filesystem2 fs2 end diff --git a/lib/ohai/plugins/darwin/memory.rb b/lib/ohai/plugins/darwin/memory.rb index 64494666..ec1bae95 100644 --- a/lib/ohai/plugins/darwin/memory.rb +++ b/lib/ohai/plugins/darwin/memory.rb @@ -17,7 +17,7 @@ # Ohai.plugin(:Memory) do - provides 'memory' + provides "memory" collect_data(:darwin) do memory Mash.new @@ -37,17 +37,17 @@ Ohai.plugin(:Memory) do end vm_stat.split("\n").each do |line| - ['wired down', 'active', 'inactive'].each do |match| + ["wired down", "active", "inactive"].each do |match| unless line.index("Pages #{match}:").nil? pages = line.split.last.to_i megabyte_val = (pages * page_size) / 1024 / 1024.0 total_consumed += megabyte_val case match - when 'wired down' + when "wired down" active += megabyte_val.to_i - when 'active' + when "active" active += megabyte_val.to_i - when 'inactive' + when "inactive" inactive += megabyte_val.to_i end end @@ -61,4 +61,3 @@ Ohai.plugin(:Memory) do memory[:free] = "#{free_memory.to_i}MB" if total_consumed > 0 end end - diff --git a/lib/ohai/plugins/darwin/network.rb b/lib/ohai/plugins/darwin/network.rb index 91454014..52febfce 100644 --- a/lib/ohai/plugins/darwin/network.rb +++ b/lib/ohai/plugins/darwin/network.rb @@ -22,7 +22,7 @@ Ohai.plugin(:Network) do def parse_media(media_string) media = Hash.new - line_array = media_string.split(' ') + line_array = media_string.split(" ") 0.upto(line_array.length - 1) do |i| unless line_array[i].eql?("none") @@ -67,7 +67,7 @@ Ohai.plugin(:Network) do end def excluded_setting?(setting) - setting.match('_sw_cksum') + setting.match("_sw_cksum") end def locate_interface(ifaces, ifname, mac) @@ -84,7 +84,7 @@ Ohai.plugin(:Network) do end collect_data(:darwin) do - require 'scanf' + require "scanf" network Mash.new unless network network[:interfaces] = Mash.new unless network[:interfaces] @@ -112,7 +112,7 @@ Ohai.plugin(:Network) do iface[cint] = Mash.new unless iface[cint]; iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] iface[cint][:mtu] = $2 if line =~ /\sflags\=\d+\<((UP|BROADCAST|DEBUG|SMART|SIMPLEX|LOOPBACK|POINTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC|,)+)\>\s/ - flags = $1.split(',') + flags = $1.split(",") else flags = Array.new end @@ -134,11 +134,11 @@ Ohai.plugin(:Network) do end if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8})\s*$/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*"."} + iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * "." } end if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*".", "broadcast" => $4 } + iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * ".", "broadcast" => $4 } end if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] @@ -185,12 +185,12 @@ Ohai.plugin(:Network) do so = shell_out("netstat -i -d -l -b -n") so.stdout.lines do |line| if line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>\s+([a-f0-9\:]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ || - line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>(\s+)(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ + line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>(\s+)(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ ifname = locate_interface(iface, $1, $2) next if iface[ifname].nil? # this shouldn't happen, but just in case net_counters[ifname] = Mash.new unless net_counters[ifname] net_counters[ifname] = { :rx => { :bytes => $5, :packets => $3, :errors => $4, :drop => 0, :overrun => 0, :frame => 0, :compressed => 0, :multicast => 0 }, - :tx => { :bytes => $8, :packets => $6, :errors => $7, :drop => 0, :overrun => 0, :collisions => $9, :carrier => 0, :compressed => 0 } + :tx => { :bytes => $8, :packets => $6, :errors => $7, :drop => 0, :overrun => 0, :collisions => $9, :carrier => 0, :compressed => 0 }, } end end diff --git a/lib/ohai/plugins/darwin/system_profiler.rb b/lib/ohai/plugins/darwin/system_profiler.rb index 59f7e2ab..ad67320e 100644 --- a/lib/ohai/plugins/darwin/system_profiler.rb +++ b/lib/ohai/plugins/darwin/system_profiler.rb @@ -21,51 +21,50 @@ Ohai.plugin(:SystemProfile) do collect_data(:darwin) do begin - require 'plist' + require "plist" system_profile Array.new - items = Array.new + items = Array.new detail_level = { - 'mini' => [ - "SPParallelATAData", - "SPAudioData", - "SPBluetoothData", - "SPCardReaderData", - "SPDiagnosticsData", - "SPDiscBurningData", - "SPEthernetData", - "SPFibreChannelData", - "SPFireWireData", - "SPDisplaysData", - "SPHardwareRAIDData", - "SPMemoryData", - "SPModemData", - "SPNetworkData", - "SPPCIData", - "SPParallelSCSIData", - "SPPrintersSoftwareData", - "SPPrintersData", - "SPSASData", - "SPSerialATAData", - "SPSoftwareData", - "SPThunderboltData", - "SPUSBData", - "SPWWANData", - "SPAirPortData" - ], - 'full' => [ + "mini" => %w{ +SPParallelATAData +SPAudioData +SPBluetoothData +SPCardReaderData +SPDiagnosticsData +SPDiscBurningData +SPEthernetData +SPFibreChannelData +SPFireWireData +SPDisplaysData +SPHardwareRAIDData +SPMemoryData +SPModemData +SPNetworkData +SPPCIData +SPParallelSCSIData +SPPrintersSoftwareData +SPPrintersData +SPSASData +SPSerialATAData +SPSoftwareData +SPThunderboltData +SPUSBData +SPWWANData +SPAirPortData}, + "full" => [ "SPHardwareDataType" - ] + ], } detail_level.each do |level, data_types| so = shell_out("system_profiler -xml -detailLevel #{level} #{data_types.join(' ')}") - Plist::parse_xml(so.stdout).each do |e| + Plist.parse_xml(so.stdout).each do |e| items << e end end - system_profile items.sort_by { |h| h['_dataType'] } + system_profile items.sort_by { |h| h["_dataType"] } rescue LoadError => e Ohai::Log.debug("Can't load gem: #{e})") end diff --git a/lib/ohai/plugins/darwin/virtualization.rb b/lib/ohai/plugins/darwin/virtualization.rb index b586d47b..2bad7152 100644 --- a/lib/ohai/plugins/darwin/virtualization.rb +++ b/lib/ohai/plugins/darwin/virtualization.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'ohai/util/file_helper' +require "ohai/util/file_helper" include Ohai::Util::FileHelper @@ -24,11 +24,11 @@ Ohai.plugin(:Virtualization) do provides "virtualization" def prlctl_exists? - which('prlctl') + which("prlctl") end def ioreg_exists? - which('ioreg') + which("ioreg") end collect_data(:darwin) do @@ -36,18 +36,18 @@ Ohai.plugin(:Virtualization) do virtualization[:systems] = Mash.new unless virtualization[:systems] if prlctl_exists? - virtualization[:system] = 'parallels' - virtualization[:role] = 'host' - virtualization[:systems][:parallels] = 'host' + virtualization[:system] = "parallels" + virtualization[:role] = "host" + virtualization[:systems][:parallels] = "host" end # Detect Parallels virtual machine from pci devices if ioreg_exists? so = shell_out("ioreg -l") if so.stdout =~ /pci1ab8,4000/ - virtualization[:system] = 'parallels' - virtualization[:role] = 'guest' - virtualization[:systems][:parallels] = 'guest' + virtualization[:system] = "parallels" + virtualization[:role] = "guest" + virtualization[:systems][:parallels] = "guest" end end end diff --git a/lib/ohai/plugins/digital_ocean.rb b/lib/ohai/plugins/digital_ocean.rb index abc5f853..a9414c41 100644 --- a/lib/ohai/plugins/digital_ocean.rb +++ b/lib/ohai/plugins/digital_ocean.rb @@ -14,21 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/util/ip_helper' +require "ohai/util/ip_helper" Ohai.plugin(:DigitalOcean) do include Ohai::Util::IpHelper - DIGITALOCEAN_FILE = '/etc/digitalocean' unless defined?(DIGITALOCEAN_FILE) + DIGITALOCEAN_FILE = "/etc/digitalocean" unless defined?(DIGITALOCEAN_FILE) provides "digital_ocean" depends "network/interfaces" def extract_droplet_ip_addresses - addresses = Mash.new({'v4' => [], 'v6' => []}) + addresses = Mash.new({ "v4" => [], "v6" => [] }) network[:interfaces].each_value do |iface| iface[:addresses].each do |address, details| - next if loopback?(address) || details[:family] == 'lladdr' + next if loopback?(address) || details[:family] == "lladdr" ip = IPAddress(address) type = digital_ocean_address_type(ip) @@ -41,32 +41,32 @@ Ohai.plugin(:DigitalOcean) do def build_address_hash(ip, details) address_hash = Mash.new({ - 'ip_address' => ip.address, - 'type' => private_address?(ip.address) ? 'private' : 'public' - }) + "ip_address" => ip.address, + "type" => private_address?(ip.address) ? "private" : "public", + },) if ip.ipv4? - address_hash['netmask'] = details[:netmask] + address_hash["netmask"] = details[:netmask] elsif ip.ipv6? - address_hash['cidr'] = ip.prefix + address_hash["cidr"] = ip.prefix end address_hash end def digital_ocean_address_type(ip) - ip.ipv4? ? 'v4' : 'v6' + ip.ipv4? ? "v4" : "v6" end def looks_like_digital_ocean? - hint?('digital_ocean') || File.exist?(DIGITALOCEAN_FILE) + hint?("digital_ocean") || File.exist?(DIGITALOCEAN_FILE) end collect_data do if looks_like_digital_ocean? Ohai::Log.debug("digitalocean plugin: looks_like_digital_ocean? == true") digital_ocean Mash.new - hint = hint?('digital_ocean') || {} - hint.each {|k, v| digital_ocean[k] = v unless k == 'ip_addresses'} + hint = hint?("digital_ocean") || {} + hint.each { |k, v| digital_ocean[k] = v unless k == "ip_addresses" } # Extract actual ip addresses # The networks sub-hash is structured similarly to how diff --git a/lib/ohai/plugins/dmi.rb b/lib/ohai/plugins/dmi.rb index e2349339..9fb019ef 100644 --- a/lib/ohai/plugins/dmi.rb +++ b/lib/ohai/plugins/dmi.rb @@ -6,9 +6,9 @@ # 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. @@ -22,7 +22,7 @@ Ohai.plugin(:DMI) do # dmidecode does not return data without access to /dev/mem (or its equivalent) collect_data do - require 'ohai/common/dmi' + require "ohai/common/dmi" dmi Mash.new # all output lines should fall within one of these patterns @@ -49,7 +49,7 @@ Ohai.plugin(:DMI) do #Handle 0x0000, DMI type 0, 24 bytes #BIOS Information # Vendor: American Megatrends Inc. - # Version: 080012 + # Version: 080012 # ... similar lines trimmed # Characteristics: # ISA is supported @@ -80,7 +80,7 @@ Ohai.plugin(:DMI) do next end - dmi_record = {:type => Ohai::Common::DMI.id_lookup(handle[2])} + dmi_record = { :type => Ohai::Common::DMI.id_lookup(handle[2]) } dmi[dmi_record[:type]] = Mash.new unless dmi.has_key?(dmi_record[:type]) dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].has_key?(:all_records) @@ -115,7 +115,7 @@ Ohai.plugin(:DMI) do next end # overwrite "raw" value with a new Mash - dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == 'Mash' + dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == "Mash" dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = nil else diff --git a/lib/ohai/plugins/dragonflybsd/cpu.rb b/lib/ohai/plugins/dragonflybsd/cpu.rb index feccd249..c9f49a86 100644 --- a/lib/ohai/plugins/dragonflybsd/cpu.rb +++ b/lib/ohai/plugins/dragonflybsd/cpu.rb @@ -44,10 +44,10 @@ Ohai.plugin(:CPU) do cpuinfo["stepping"] = $3 # These _should_ match /AMD Features2?/ lines as well when /Features=.+<(.+)>/ - cpuinfo["flags"].concat($1.downcase.split(',')) + cpuinfo["flags"].concat($1.downcase.split(",")) # Features2=0x80000001> when /Features2=[a-f\dx]+<(.+)>/ - cpuinfo["flags"].concat($1.downcase.split(',')) + cpuinfo["flags"].concat($1.downcase.split(",")) end end diff --git a/lib/ohai/plugins/dragonflybsd/memory.rb b/lib/ohai/plugins/dragonflybsd/memory.rb index 47618698..a4ff7165 100644 --- a/lib/ohai/plugins/dragonflybsd/memory.rb +++ b/lib/ohai/plugins/dragonflybsd/memory.rb @@ -57,4 +57,3 @@ Ohai.plugin(:Memory) do end end end - diff --git a/lib/ohai/plugins/dragonflybsd/network.rb b/lib/ohai/plugins/dragonflybsd/network.rb index cc80903a..48d2ecdc 100644 --- a/lib/ohai/plugins/dragonflybsd/network.rb +++ b/lib/ohai/plugins/dragonflybsd/network.rb @@ -58,7 +58,7 @@ Ohai.plugin(:Network) do if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] # convert the netmask to decimal for consistency - netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}" + netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}" if $3.empty? iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask } else @@ -76,7 +76,7 @@ Ohai.plugin(:Network) do end end if line =~ /flags=\d+<(.+)>/ - flags = $1.split(',') + flags = $1.split(",") iface[cint][:flags] = flags if flags.length > 0 end if line =~ /metric: (\d+) mtu: (\d+)/ @@ -100,11 +100,11 @@ Ohai.plugin(:Network) do # From netstat(1), not sure of the implications: # Show the state of all network interfaces or a single interface # which have been auto-configured (interfaces statically configured - # into a system, but not located at boot time are not shown). + # into a system, but not located at boot time are not shown). so = shell_out("netstat -ibdn") so.stdout.lines do |line| # Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop - # ed0 1500 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905 + # ed0 1500 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905 # $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 if line =~ /^([\w\.\*]+)\s+\d+\s+\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ net_counters[$1] = Mash.new unless net_counters[$1] diff --git a/lib/ohai/plugins/dragonflybsd/os.rb b/lib/ohai/plugins/dragonflybsd/os.rb index 94977e52..836ee25f 100644 --- a/lib/ohai/plugins/dragonflybsd/os.rb +++ b/lib/ohai/plugins/dragonflybsd/os.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'ohai/mixin/os' +require "ohai/mixin/os" Ohai.plugin(:OS) do provides "os", "os_version" diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb index 77f35e5e..769ea9c2 100644 --- a/lib/ohai/plugins/ec2.rb +++ b/lib/ohai/plugins/ec2.rb @@ -17,8 +17,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/mixin/ec2_metadata' -require 'base64' +require "ohai/mixin/ec2_metadata" +require "base64" Ohai.plugin(:EC2) do include Ohai::Mixin::Ec2Metadata @@ -30,7 +30,7 @@ Ohai.plugin(:EC2) do # look for ec2metadata which is included on paravirt / hvm AMIs def has_ec2metadata_bin? - if File.exist?('/usr/bin/ec2metadata') + if File.exist?("/usr/bin/ec2metadata") Ohai::Log.debug("ec2 plugin: has_ec2metadata_bin? == true") true else @@ -75,11 +75,11 @@ EOM end def looks_like_ec2? - return true if hint?('ec2') + return true if hint?("ec2") # if has ec2 mac try non-blocking connect so we don't "block" if # the Xen environment is *not* EC2 - return true if (has_ec2metadata_bin? || has_ec2_dmi?) || (has_xen_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)) + return true if (has_ec2metadata_bin? || has_ec2_dmi?) || (has_xen_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)) end collect_data do @@ -91,7 +91,7 @@ EOM # secret access key. We'd rather not have ohai send this information # to the server. # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories - next if k == 'iam' && !hint?('iam') + next if k == "iam" && !hint?("iam") ec2[k] = v end ec2[:userdata] = self.fetch_userdata diff --git a/lib/ohai/plugins/elixir.rb b/lib/ohai/plugins/elixir.rb index 1beca40b..2733b3c2 100644 --- a/lib/ohai/plugins/elixir.rb +++ b/lib/ohai/plugins/elixir.rb @@ -24,7 +24,7 @@ Ohai.plugin(:Elixir) do elixir = Mash.new so = shell_out("elixir -v") if so.exitstatus == 0 - output = so.stdout.split + output = so.stdout.split elixir[:version] = output[1] languages[:elixir] = elixir if elixir[:version] end diff --git a/lib/ohai/plugins/erlang.rb b/lib/ohai/plugins/erlang.rb index 26179fde..f9356fd3 100644 --- a/lib/ohai/plugins/erlang.rb +++ b/lib/ohai/plugins/erlang.rb @@ -30,10 +30,10 @@ Ohai.plugin(:Erlang) do output = so.stderr.split if output.length >= 6 options = output[1] - options.gsub!(/(\(|\))/, '') + options.gsub!(/(\(|\))/, "") erlang[:version] = output[5] - erlang[:options] = options.split(',') - erlang[:emulator] = output[2].gsub!(/(\(|\))/, '') + erlang[:options] = options.split(",") + erlang[:emulator] = output[2].gsub!(/(\(|\))/, "") if erlang[:version] and erlang[:options] and erlang[:emulator] languages[:erlang] = erlang end diff --git a/lib/ohai/plugins/eucalyptus.rb b/lib/ohai/plugins/eucalyptus.rb index 0a0c0b4b..6fd427c5 100644 --- a/lib/ohai/plugins/eucalyptus.rb +++ b/lib/ohai/plugins/eucalyptus.rb @@ -18,7 +18,7 @@ # limitations under the License. # eucalyptus metadata service is compatible with the ec2 service calls -require 'ohai/mixin/ec2_metadata' +require "ohai/mixin/ec2_metadata" Ohai.plugin(:Eucalyptus) do include Ohai::Mixin::Ec2Metadata @@ -28,7 +28,7 @@ Ohai.plugin(:Eucalyptus) do # returns the mac address from the collection of all address types def get_mac_address(addresses) - detected_addresses = addresses.detect { |address, keypair| keypair == {"family"=>"lladdr"} } + detected_addresses = addresses.detect { |address, keypair| keypair == { "family" => "lladdr" } } if detected_addresses return detected_addresses.first else @@ -53,7 +53,7 @@ Ohai.plugin(:Eucalyptus) do def looks_like_euca? # Try non-blocking connect so we don't "block" if # the metadata service doesn't respond - hint?('eucalyptus') || has_euca_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80) + hint?("eucalyptus") || has_euca_mac? && can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80) end collect_data do @@ -68,7 +68,7 @@ Ohai.plugin(:Eucalyptus) do # secret access key. We'd rather not have ohai send this information # to the server. # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html#instancedata-data-categories - next if k == 'iam' && !hint?('iam') + next if k == "iam" && !hint?("iam") eucalyptus[k] = v end eucalyptus[:userdata] = self.fetch_userdata diff --git a/lib/ohai/plugins/freebsd/cpu.rb b/lib/ohai/plugins/freebsd/cpu.rb index 27a7dfa2..5d75308e 100644 --- a/lib/ohai/plugins/freebsd/cpu.rb +++ b/lib/ohai/plugins/freebsd/cpu.rb @@ -53,10 +53,10 @@ Ohai.plugin(:CPU) do cpuinfo["stepping"] = $4 # These _should_ match /AMD Features2?/ lines as well when /Features=.+<(.+)>/ - cpuinfo["flags"].concat($1.downcase.split(',')) + cpuinfo["flags"].concat($1.downcase.split(",")) # Features2=0x80000001> when /Features2=[a-f\dx]+<(.+)>/ - cpuinfo["flags"].concat($1.downcase.split(',')) + cpuinfo["flags"].concat($1.downcase.split(",")) when /FreeBSD\/SMP: Multiprocessor System Detected: (\d*) CPUs/ cpuinfo["total"] = $1.to_i when /FreeBSD\/SMP: (\d*) package\(s\) x (\d*) core\(s\)/ diff --git a/lib/ohai/plugins/freebsd/memory.rb b/lib/ohai/plugins/freebsd/memory.rb index 842f9689..fdf32a30 100644 --- a/lib/ohai/plugins/freebsd/memory.rb +++ b/lib/ohai/plugins/freebsd/memory.rb @@ -57,4 +57,3 @@ Ohai.plugin(:Memory) do end end end - diff --git a/lib/ohai/plugins/freebsd/network.rb b/lib/ohai/plugins/freebsd/network.rb index 6a31144a..efcaabb1 100644 --- a/lib/ohai/plugins/freebsd/network.rb +++ b/lib/ohai/plugins/freebsd/network.rb @@ -58,7 +58,7 @@ Ohai.plugin(:Network) do if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] # convert the netmask to decimal for consistency - netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}" + netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}" if $3.empty? iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask } else @@ -76,7 +76,7 @@ Ohai.plugin(:Network) do end end if line =~ /flags=\d+<(.+)>/ - flags = $1.split(',') + flags = $1.split(",") iface[cint][:flags] = flags if flags.length > 0 end if line =~ /metric: (\d+) mtu: (\d+)/ @@ -100,11 +100,11 @@ Ohai.plugin(:Network) do # From netstat(1), not sure of the implications: # Show the state of all network interfaces or a single interface # which have been auto-configured (interfaces statically configured - # into a system, but not located at boot time are not shown). + # into a system, but not located at boot time are not shown). so = shell_out("netstat -ibdn") so.stdout.lines do |line| # Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop - # ed0 1500 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905 + # ed0 1500 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905 # $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 if line =~ /^([\w\.\*]+)\s+\d+\s+\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ net_counters[$1] = Mash.new unless net_counters[$1] diff --git a/lib/ohai/plugins/freebsd/os.rb b/lib/ohai/plugins/freebsd/os.rb index d2c8a326..ee1c9d0b 100644 --- a/lib/ohai/plugins/freebsd/os.rb +++ b/lib/ohai/plugins/freebsd/os.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'ohai/mixin/os' +require "ohai/mixin/os" Ohai.plugin(:OS) do provides "os", "os_version" diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb index 82abaf08..275a9770 100644 --- a/lib/ohai/plugins/gce.rb +++ b/lib/ohai/plugins/gce.rb @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/mixin/gce_metadata' +require "ohai/mixin/gce_metadata" Ohai.plugin(:GCE) do include Ohai::Mixin::GCEMetadata @@ -27,7 +27,7 @@ Ohai.plugin(:GCE) do # true:: If gce metadata server found # false:: Otherwise def has_gce_metadata? - can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80) + can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80) end # Identifies gce @@ -36,14 +36,14 @@ Ohai.plugin(:GCE) do # true:: If gce can be identified # false:: Otherwise def looks_like_gce? - hint?('gce') || has_gce_metadata? + hint?("gce") || has_gce_metadata? end collect_data do if looks_like_gce? Ohai::Log.debug("gce plugin: looks_like_gce? == true") gce Mash.new - fetch_metadata.each {|k, v| gce[k] = v } + fetch_metadata.each { |k, v| gce[k] = v } else Ohai::Log.debug("gce plugin: looks_like_gce? == false") false diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb index f12b1940..fb97d971 100644 --- a/lib/ohai/plugins/hostname.rb +++ b/lib/ohai/plugins/hostname.rb @@ -25,8 +25,8 @@ # limitations under the License. # -require 'socket' -require 'ipaddr' +require "socket" +require "ipaddr" Ohai.plugin(:Hostname) do provides "domain", "hostname", "fqdn", "machinename" @@ -77,14 +77,14 @@ Ohai.plugin(:Hostname) do end def get_fqdn_from_sigar - require 'sigar' + require "sigar" sigar = Sigar.new sigar.fqdn end def sigar_is_available? begin - require 'sigar' + require "sigar" true rescue LoadError false @@ -153,11 +153,11 @@ Ohai.plugin(:Hostname) do end collect_data(:windows) do - require 'wmi-lite/wmi' - require 'socket' + require "wmi-lite/wmi" + require "socket" wmi = WmiLite::Wmi.new - host = wmi.first_of('Win32_ComputerSystem') + host = wmi.first_of("Win32_ComputerSystem") hostname "#{host['dnshostname']}" machinename "#{host['name']}" diff --git a/lib/ohai/plugins/init_package.rb b/lib/ohai/plugins/init_package.rb index f648240b..1bf54ce1 100644 --- a/lib/ohai/plugins/init_package.rb +++ b/lib/ohai/plugins/init_package.rb @@ -20,6 +20,6 @@ Ohai.plugin(:InitPackage) do provides "init_package" collect_data(:linux) do - init_package File.exists?("/proc/1/comm") ? File.open("/proc/1/comm").gets.chomp : 'init' + init_package File.exists?("/proc/1/comm") ? File.open("/proc/1/comm").gets.chomp : "init" end end diff --git a/lib/ohai/plugins/ip_scopes.rb b/lib/ohai/plugins/ip_scopes.rb index 7cb7e50d..b74ab2f7 100644 --- a/lib/ohai/plugins/ip_scopes.rb +++ b/lib/ohai/plugins/ip_scopes.rb @@ -6,9 +6,9 @@ # 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. @@ -22,15 +22,15 @@ Ohai.plugin(:IpScopes) do collect_data do begin - require 'ipaddr_extensions' + require "ipaddr_extensions" - network['interfaces'].keys.sort.each do |ifName| - next if network['interfaces'][ifName]['addresses'].nil? + network["interfaces"].keys.sort.each do |ifName| + next if network["interfaces"][ifName]["addresses"].nil? - interface = network['interfaces'][ifName] - interface['addresses'].each do |address,attrs| + interface = network["interfaces"][ifName] + interface["addresses"].each do |address, attrs| begin - attrs.merge! 'ip_scope' => address.to_ip.scope + attrs.merge! "ip_scope" => address.to_ip.scope if private_addr?(address) && !tunnel_iface?(interface) privateaddress(address) @@ -52,6 +52,6 @@ Ohai.plugin(:IpScopes) do end def tunnel_iface?(interface) - interface['type'] == 'ppp' + interface["type"] == "ppp" end end diff --git a/lib/ohai/plugins/joyent.rb b/lib/ohai/plugins/joyent.rb index 0b91fdf1..c921d65d 100644 --- a/lib/ohai/plugins/joyent.rb +++ b/lib/ohai/plugins/joyent.rb @@ -20,9 +20,9 @@ # Reference from: sm-summary command Ohai.plugin(:Joyent) do - provides 'joyent' - provides 'virtualization/guest_id' - depends 'os', 'platform', 'virtualization' + provides "joyent" + provides "virtualization/guest_id" + depends "os", "platform", "virtualization" def collect_product_file lines = [] @@ -37,7 +37,7 @@ Ohai.plugin(:Joyent) do end def collect_pkgsrc - if File.exist?('/opt/local/etc/pkg_install.conf') + if File.exist?("/opt/local/etc/pkg_install.conf") sm_pkgsrc = ::File.read("/opt/local/etc/pkg_install.conf").split("=") sm_pkgsrc[1].chomp else @@ -46,7 +46,7 @@ Ohai.plugin(:Joyent) do end def is_smartos? - platform == 'smartos' + platform == "smartos" end collect_data do @@ -58,14 +58,14 @@ Ohai.plugin(:Joyent) do # get zone id unless globalzone unless joyent[:sm_uuid] == "global" - joyent[:sm_id] = virtualization[:guest_id] + joyent[:sm_id] = virtualization[:guest_id] end # retrieve image name and pkgsrc collect_product_file.each do |line| case line when /^Image/ - sm_image = line.split(" ") + sm_image = line.split(" ") joyent[:sm_image_id] = sm_image[1] joyent[:sm_image_ver] = sm_image[2] when /^Base Image/ diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb index bbbf5f62..59665bba 100644 --- a/lib/ohai/plugins/kernel.rb +++ b/lib/ohai/plugins/kernel.rb @@ -80,7 +80,7 @@ Ohai.plugin(:Kernel) do so = shell_out("sysctl -n hw.optional.x86_64") if so.stdout.split($/)[0].to_i == 1 - kernel[:machine] = 'x86_64' + kernel[:machine] = "x86_64" end modules = Mash.new @@ -157,10 +157,10 @@ Ohai.plugin(:Kernel) do # EXAMPLE: # Id Loadaddr Size Info Rev Module Name # 6 1180000 4623 1 1 specfs (filesystem for specfs) - module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/ + module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/ so.stdout.lines do |line| if mod = module_description.match(line) - modules[mod[4]] = { :id => mod[1].to_i, :loadaddr => mod[2], :size => mod[3].to_i(16), :description => mod[5]} + modules[mod[4]] = { :id => mod[1].to_i, :loadaddr => mod[2], :size => mod[3].to_i(16), :description => mod[5] } end end @@ -168,8 +168,8 @@ Ohai.plugin(:Kernel) do end collect_data(:windows) do - require 'win32ole' - require 'wmi-lite/wmi' + require "win32ole" + require "wmi-lite/wmi" WIN32OLE.codepage = WIN32OLE::CP_UTF8 @@ -177,7 +177,7 @@ Ohai.plugin(:Kernel) do kernel Mash.new - host = wmi.first_of('Win32_OperatingSystem') + host = wmi.first_of("Win32_OperatingSystem") kernel[:os_info] = Mash.new host.wmi_ole_object.properties_.each do |p| kernel[:os_info][p.name.wmi_underscore.to_sym] = host[p.name.downcase] @@ -188,10 +188,10 @@ Ohai.plugin(:Kernel) do kernel[:version] = "#{kernel[:os_info][:version]} #{kernel[:os_info][:csd_version]} Build #{kernel[:os_info][:build_number]}" kernel[:os] = os_lookup(kernel[:os_info][:os_type]) || languages[:ruby][:host_os] - host = wmi.first_of('Win32_ComputerSystem') + host = wmi.first_of("Win32_ComputerSystem") kernel[:cs_info] = Mash.new cs_info_blacklist = [ - 'oem_logo_bitmap' + "oem_logo_bitmap" ] host.wmi_ole_object.properties_.each do |p| if !cs_info_blacklist.include?(p.name.wmi_underscore) diff --git a/lib/ohai/plugins/linode.rb b/lib/ohai/plugins/linode.rb index a585783d..1d122cd9 100644 --- a/lib/ohai/plugins/linode.rb +++ b/lib/ohai/plugins/linode.rb @@ -25,7 +25,7 @@ Ohai.plugin(:Linode) do # Returns true or false def has_linode_kernel? if kernel_data = kernel - kernel_data[:release].split('-').last =~ /linode/ + kernel_data[:release].split("-").last =~ /linode/ end end @@ -33,7 +33,7 @@ Ohai.plugin(:Linode) do # # Returns true or false def looks_like_linode? - hint?('linode') || has_linode_kernel? + hint?("linode") || has_linode_kernel? end # Names linode ip address @@ -45,7 +45,7 @@ Ohai.plugin(:Linode) do def get_ip_address(name, eth) if eth_iface = network[:interfaces][eth] eth_iface[:addresses].each do |key, info| - linode[name] = key if info['family'] == 'inet' + linode[name] = key if info["family"] == "inet" end end end @@ -57,7 +57,7 @@ Ohai.plugin(:Linode) do linode Mash.new get_ip_address(:public_ip, :eth0) get_ip_address(:private_ip, "eth0:1") - hint?('linode').each{|k,v| linode[k] = v } if hint?('linode').kind_of?(Hash) + hint?("linode").each { |k, v| linode[k] = v } if hint?("linode").kind_of?(Hash) else Ohai::Log.debug("linode plugin: looks_like_linode? == false") end diff --git a/lib/ohai/plugins/linux/cpu.rb b/lib/ohai/plugins/linux/cpu.rb index 174e9576..9b9e0b72 100644 --- a/lib/ohai/plugins/linux/cpu.rb +++ b/lib/ohai/plugins/linux/cpu.rb @@ -58,18 +58,18 @@ Ohai.plugin(:CPU) do when /cache size\s+:\s(.+)/ cpuinfo[current_cpu]["cache_size"] = $1 when /flags\s+:\s(.+)/ - cpuinfo[current_cpu]["flags"] = $1.split(' ') + cpuinfo[current_cpu]["flags"] = $1.split(" ") when /bogomips per cpu:\s(.+)/ cpuinfo["bogomips_per_cpu"] = $1 when /features\s+:\s(.+)/ - cpuinfo["features"] = $1.split(' ') + cpuinfo["features"] = $1.split(" ") when /processor\s(\d):\s(.+)/ current_cpu = $1 cpu_number += 1 cpuinfo[current_cpu] = Mash.new - current_cpu_info = $2.split(',') + current_cpu_info = $2.split(",") for i in current_cpu_info - name_value = i.split('=') + name_value = i.split("=") name = name_value[0].strip value = name_value[1].strip cpuinfo[current_cpu][name] = value diff --git a/lib/ohai/plugins/linux/filesystem.rb b/lib/ohai/plugins/linux/filesystem.rb index 37b42c6f..35e7224a 100644 --- a/lib/ohai/plugins/linux/filesystem.rb +++ b/lib/ohai/plugins/linux/filesystem.rb @@ -21,7 +21,7 @@ Ohai.plugin(:Filesystem) do def get_blk_cmd(attr, have_lsblk) if have_lsblk - attr = 'FSTYPE' if attr == 'TYPE' + attr = "FSTYPE" if attr == "TYPE" "lsblk -P -n -o NAME,#{attr}" else "blkid -s #{attr}" @@ -30,7 +30,7 @@ Ohai.plugin(:Filesystem) do def get_blk_regex(attr, have_lsblk) if have_lsblk - attr = 'FSTYPE' if attr == 'TYPE' + attr = "FSTYPE" if attr == "TYPE" /^NAME="(\S+).*?" #{attr}="(\S+)"/ else /^(\S+): #{attr}="(\S+)"/ @@ -47,7 +47,7 @@ Ohai.plugin(:Filesystem) do collect_data(:linux) do fs = Mash.new - have_lsblk = File.executable?('/bin/lsblk') + have_lsblk = File.executable?("/bin/lsblk") # Grab filesystem data from df so = shell_out("df -P") @@ -95,56 +95,56 @@ Ohai.plugin(:Filesystem) do end end - have_lsblk = File.exist?('/bin/lsblk') + have_lsblk = File.exist?("/bin/lsblk") # Gather more filesystem types via libuuid, even devices that's aren't mounted - cmd = get_blk_cmd('TYPE', have_lsblk) - regex = get_blk_regex('TYPE', have_lsblk) + cmd = get_blk_cmd("TYPE", have_lsblk) + regex = get_blk_regex("TYPE", have_lsblk) so = shell_out(cmd) so.stdout.lines do |line| if line =~ regex filesystem = $1 type = $2 - filesystem = find_device(filesystem) unless filesystem.start_with?('/') + filesystem = find_device(filesystem) unless filesystem.start_with?("/") fs[filesystem] = Mash.new unless fs.has_key?(filesystem) fs[filesystem][:fs_type] = type end end # Gather device UUIDs via libuuid - cmd = get_blk_cmd('UUID', have_lsblk) - regex = get_blk_regex('UUID', have_lsblk) + cmd = get_blk_cmd("UUID", have_lsblk) + regex = get_blk_regex("UUID", have_lsblk) so = shell_out(cmd) so.stdout.lines do |line| if line =~ regex filesystem = $1 uuid = $2 - filesystem = find_device(filesystem) unless filesystem.start_with?('/') + filesystem = find_device(filesystem) unless filesystem.start_with?("/") fs[filesystem] = Mash.new unless fs.has_key?(filesystem) fs[filesystem][:uuid] = uuid end end # Gather device labels via libuuid - cmd = get_blk_cmd('LABEL', have_lsblk) - regex = get_blk_regex('LABEL', have_lsblk) + cmd = get_blk_cmd("LABEL", have_lsblk) + regex = get_blk_regex("LABEL", have_lsblk) so = shell_out(cmd) so.stdout.lines do |line| if line =~ regex filesystem = $1 label = $2 - filesystem = find_device(filesystem) unless filesystem.start_with?('/') + filesystem = find_device(filesystem) unless filesystem.start_with?("/") fs[filesystem] = Mash.new unless fs.has_key?(filesystem) fs[filesystem][:label] = label end end # Grab any missing mount information from /proc/mounts - if File.exist?('/proc/mounts') - mounts = '' + if File.exist?("/proc/mounts") + mounts = "" # Due to https://tickets.opscode.com/browse/OHAI-196 # we have to non-block read dev files. Ew. - f = File.open('/proc/mounts') + f = File.open("/proc/mounts") loop do begin data = f.read_nonblock(4096) diff --git a/lib/ohai/plugins/linux/filesystem2.rb b/lib/ohai/plugins/linux/filesystem2.rb index bb0b6464..1268ad63 100644 --- a/lib/ohai/plugins/linux/filesystem2.rb +++ b/lib/ohai/plugins/linux/filesystem2.rb @@ -34,16 +34,16 @@ Ohai.plugin(:Filesystem2) do regex = /NAME="(\S+).*?" UUID="(\S*)" LABEL="(\S*)" FSTYPE="(\S*)"/ if line =~ regex dev = $1 - dev = find_device(dev) unless dev.start_with?('/') + dev = find_device(dev) unless dev.start_with?("/") uuid = $2 label = $3 fs_type = $4 - return {:dev => dev, :uuid => uuid, :label => label, :fs_type => fs_type} + return { :dev => dev, :uuid => uuid, :label => label, :fs_type => fs_type } end else bits = line.split - dev = bits.shift.split(':')[0] - f = {:dev => dev} + dev = bits.shift.split(":")[0] + f = { :dev => dev } bits.each do |keyval| if keyval =~ /(\S+)="(\S+)"/ key = $1.downcase.to_sym @@ -61,7 +61,7 @@ Ohai.plugin(:Filesystem2) do fs.each_value do |entry| view[entry[:device]] = Mash.new unless view[entry[:device]] entry.each do |key, val| - next if ['device', 'mount'].include?(key) + next if %w{device mount}.include?(key) view[entry[:device]][key] = val end view[entry[:device]][:mounts] ||= [] @@ -78,7 +78,7 @@ Ohai.plugin(:Filesystem2) do next unless entry[:mount] view[entry[:mount]] = Mash.new unless view[entry[:mount]] entry.each do |key, val| - next if ['mount', 'device'].include?(key) + next if %w{mount device}.include?(key) view[entry[:mount]][key] = val end view[entry[:mount]][:devices] ||= [] @@ -141,12 +141,12 @@ Ohai.plugin(:Filesystem2) do end end - have_lsblk = File.exist?('/bin/lsblk') + have_lsblk = File.exist?("/bin/lsblk") if have_lsblk - cmd = 'lsblk -n -P -o NAME,UUID,LABEL,FSTYPE' + cmd = "lsblk -n -P -o NAME,UUID,LABEL,FSTYPE" else # CentOS5 and other platforms don't have lsblk - cmd = 'blkid' + cmd = "blkid" end so = shell_out(cmd) @@ -177,11 +177,11 @@ Ohai.plugin(:Filesystem2) do end # Grab any missing mount information from /proc/mounts - if File.exist?('/proc/mounts') - mounts = '' + if File.exist?("/proc/mounts") + mounts = "" # Due to https://tickets.opscode.com/browse/OHAI-196 # we have to non-block read dev files. Ew. - f = File.open('/proc/mounts') + f = File.open("/proc/mounts") loop do begin data = f.read_nonblock(4096) @@ -213,9 +213,9 @@ Ohai.plugin(:Filesystem2) do by_mountpoint = generate_mountpoint_view(fs) fs2 = Mash.new - fs2['by_device'] = by_device - fs2['by_mountpoint'] = by_mountpoint - fs2['by_pair'] = by_pair + fs2["by_device"] = by_device + fs2["by_mountpoint"] = by_mountpoint + fs2["by_pair"] = by_pair # Set the filesystem data filesystem2 fs2 diff --git a/lib/ohai/plugins/linux/mdadm.rb b/lib/ohai/plugins/linux/mdadm.rb index fdc08ff5..0075750a 100644 --- a/lib/ohai/plugins/linux/mdadm.rb +++ b/lib/ohai/plugins/linux/mdadm.rb @@ -17,7 +17,7 @@ # Ohai.plugin(:Mdadm) do - provides 'mdadm' + provides "mdadm" def create_raid_device_mash(stdout) device_mash = Mash.new @@ -51,9 +51,9 @@ Ohai.plugin(:Mdadm) do collect_data(:linux) do # gather a list of all raid arrays - if File.exist?('/proc/mdstat') + if File.exist?("/proc/mdstat") devices = [] - File.open('/proc/mdstat').each do |line| + File.open("/proc/mdstat").each do |line| devices << Regexp.last_match[1] if line =~ /(md[0-9]+)/ end diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb index e2a5c887..32b77650 100644 --- a/lib/ohai/plugins/linux/network.rb +++ b/lib/ohai/plugins/linux/network.rb @@ -46,11 +46,11 @@ Ohai.plugin(:Network) do end def is_openvz? - ::File.directory?('/proc/vz') + ::File.directory?("/proc/vz") end def is_openvz_host? - is_openvz? && ::File.directory?('/proc/bc') + is_openvz? && ::File.directory?("/proc/bc") end def extract_neighbors(family, iface, neigh_attr) @@ -98,7 +98,7 @@ Ohai.plugin(:Network) do Ohai::Log.debug("Skipping route entry without a device: '#{line}'") next end - route_int = 'venet0:0' if is_openvz? && !is_openvz_host? && route_int == 'venet0' && iface['venet0:0'] + route_int = "venet0:0" if is_openvz? && !is_openvz_host? && route_int == "venet0" && iface["venet0:0"] unless iface[route_int] Ohai::Log.debug("Skipping previously unseen interface from 'ip route show': #{route_int}") @@ -107,7 +107,7 @@ Ohai.plugin(:Network) do route_entry = Mash.new(:destination => route_dest, :family => family[:name]) - %w[via scope metric proto src].each do |k| + %w{via scope metric proto src}.each do |k| route_entry[k] = $1 if route_ending =~ /\b#{k}\s+([^\s]+)\b/ end @@ -141,19 +141,19 @@ Ohai.plugin(:Network) do # determine layer 1 details for the interface using ethtool def ethernet_layer_one(iface) return iface unless ethtool_binary = find_ethtool_binary - keys = %w[ Speed Duplex Port Transceiver Auto-negotiation MDI-X ] + keys = %w{ Speed Duplex Port Transceiver Auto-negotiation MDI-X } iface.each_key do |tmp_int| - next unless iface[tmp_int][:encapsulation] == 'Ethernet' + next unless iface[tmp_int][:encapsulation] == "Ethernet" so = shell_out("#{ethtool_binary} #{tmp_int}") so.stdout.lines do |line| line.chomp! Ohai::Log.debug("Parsing ethtool output: #{line}") line.lstrip! - k, v = line.split(': ') + k, v = line.split(": ") next unless keys.include? k - k.downcase!.tr!('-', '_') - if k == 'speed' - k = 'link_speed' # This is not necessarily the maximum speed the NIC supports + k.downcase!.tr!("-", "_") + if k == "speed" + k = "link_speed" # This is not necessarily the maximum speed the NIC supports v = v[/\d+/].to_i end iface[tmp_int][k] = v @@ -181,7 +181,7 @@ Ohai.plugin(:Network) do net_counters[tmp_int][int][:packets] = $2 net_counters[tmp_int][int][:errors] = $3 net_counters[tmp_int][int][:drop] = $4 - if (int == :rx) + if int == :rx net_counters[tmp_int][int][:overrun] = $5 else net_counters[tmp_int][int][:carrier] = $5 @@ -214,7 +214,7 @@ Ohai.plugin(:Network) do end if line =~ /state (\w+)/ - iface[tmp_int]['state'] = $1.downcase + iface[tmp_int]["state"] = $1.downcase end end iface @@ -258,7 +258,7 @@ Ohai.plugin(:Network) do iface[cint][:encapsulation] = linux_encaps_lookup($1) unless $2 == "00:00:00:00:00:00" iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][$2.upcase] = {"family" => "lladdr"} + iface[cint][:addresses][$2.upcase] = { "family" => "lladdr" } end end end @@ -279,7 +279,7 @@ Ohai.plugin(:Network) do iface[cint] = Mash.new unless iface[cint] # Create the fake alias interface if needed iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][tmp_addr] = {"family" => "inet", "prefixlen" => tmp_prefix} + iface[cint][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix } iface[cint][:addresses][tmp_addr][:netmask] = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s if line =~ /peer (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ @@ -304,20 +304,20 @@ Ohai.plugin(:Network) do if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] tmp_addr = $1 - iface[cint][:addresses][tmp_addr] = {"family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("host") ? "Node" : $3.capitalize)} + iface[cint][:addresses][tmp_addr] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("host") ? "Node" : $3.capitalize) } end end # returns the macaddress for interface from a hash of interfaces (iface elsewhere in this file) def get_mac_for_interface(interfaces, interface) - interfaces[interface][:addresses].select{|k,v| v["family"]=="lladdr"}.first.first unless interfaces[interface][:flags].include? "NOARP" + interfaces[interface][:addresses].select { |k, v| v["family"] == "lladdr" }.first.first unless interfaces[interface][:flags].include? "NOARP" end # returns the default route with the lowest metric (unspecified metric is 0) def choose_default_route(routes) default_route = routes.select do |r| r[:destination] == "default" - end.sort do |x,y| + end.sort do |x, y| (x[:metric].nil? ? 0 : x[:metric].to_i) <=> (y[:metric].nil? ? 0 : y[:metric].to_i) end.first end @@ -365,7 +365,7 @@ Ohai.plugin(:Network) do IPAddress( r[:destination] == "default" ? family[:default_route] : r[:destination] ).prefix rescue 0 - end + end, ] end.first end @@ -374,7 +374,7 @@ Ohai.plugin(:Network) do # If the 'ip' binary is available, this plugin may set {ip,mac,ip6}address. The network plugin should not overwrite these. # The older code section below that relies on the deprecated net-tools, e.g. netstat and ifconfig, provides less functionality. collect_data(:linux) do - require 'ipaddr' + require "ipaddr" iface = Mash.new net_counters = Mash.new @@ -386,7 +386,7 @@ Ohai.plugin(:Network) do # ohai.plugin[:network][:default_route_table] = 'default' if configuration(:default_route_table).nil? || configuration(:default_route_table).empty? - default_route_table = 'main' + default_route_table = "main" else default_route_table = configuration(:default_route_table) end @@ -403,14 +403,14 @@ Ohai.plugin(:Network) do :name => "inet", :default_route => "0.0.0.0/0", :default_prefix => :default, - :neighbour_attribute => :arp + :neighbour_attribute => :arp, }] families << { :name => "inet6", :default_route => "::/0", :default_prefix => :default_inet6, - :neighbour_attribute => :neighbour_inet6 + :neighbour_attribute => :neighbour_inet6, } if ipv6_enabled? parse_ip_addr(iface) @@ -476,7 +476,7 @@ Ohai.plugin(:Network) do begin so = shell_out("route -n") route_result = so.stdout.split($/).grep( /^0.0.0.0/ )[0].split( /[ \t]+/ ) - network[:default_gateway], network[:default_interface] = route_result.values_at(1,7) + network[:default_gateway], network[:default_interface] = route_result.values_at(1, 7) rescue Ohai::Exceptions::Exec Ohai::Log.debug("Unable to determine default interface") end diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb index 6a655b85..9455e788 100644 --- a/lib/ohai/plugins/linux/platform.rb +++ b/lib/ohai/plugins/linux/platform.rb @@ -38,8 +38,8 @@ Ohai.plugin(:Platform) do def read_os_release_info(file) return nil unless File.exist?(file) File.read(file).split.inject({}) do |map, line| - key, value = line.split('=') - map[key] = value.gsub(/\A"|"\Z/, '') if value + key, value = line.split("=") + map[key] = value.gsub(/\A"|"\Z/, "") if value map end end @@ -54,8 +54,8 @@ Ohai.plugin(:Platform) do def os_release_info @os_release_info ||= begin - os_release_info = read_os_release_info('/etc/os-release') - cisco_release_info = os_release_info['CISCO_RELEASE_INFO'] if os_release_info + os_release_info = read_os_release_info("/etc/os-release") + cisco_release_info = os_release_info["CISCO_RELEASE_INFO"] if os_release_info if cisco_release_info && File.exist?(cisco_release_info) os_release_info.merge!(read_os_release_info(cisco_release_info)) end @@ -69,7 +69,7 @@ Ohai.plugin(:Platform) do # @returns [Boolean] if we are Cisco according to /etc/os-release # def os_release_file_is_cisco? - File.exist?('/etc/os-release') && os_release_info['CISCO_RELEASE_INFO'] + File.exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"] end collect_data(:linux) do @@ -105,8 +105,8 @@ Ohai.plugin(:Platform) do platform_version contents.match(/(\d\.\d\.\d)/)[0] elsif File.exist?("/etc/redhat-release") if os_release_file_is_cisco? # Cisco guestshell - platform 'nexus_centos' - platform_version os_release_info['VERSION'] + platform "nexus_centos" + platform_version os_release_info["VERSION"] else contents = File.read("/etc/redhat-release").chomp platform get_redhatish_platform(contents) @@ -116,10 +116,10 @@ Ohai.plugin(:Platform) do contents = File.read("/etc/system-release").chomp platform get_redhatish_platform(contents) platform_version get_redhatish_version(contents) - elsif File.exist?('/etc/gentoo-release') + elsif File.exist?("/etc/gentoo-release") platform "gentoo" - platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join - elsif File.exist?('/etc/SuSE-release') + platform_version File.read("/etc/gentoo-release").scan(/(\d+|\.+)/).join + elsif File.exist?("/etc/SuSE-release") suse_release = File.read("/etc/SuSE-release") suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".") suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == "" @@ -129,37 +129,37 @@ Ohai.plugin(:Platform) do else platform "suse" end - elsif File.exist?('/etc/slackware-version') + elsif File.exist?("/etc/slackware-version") platform "slackware" platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join - elsif File.exist?('/etc/arch-release') + elsif File.exist?("/etc/arch-release") platform "arch" # no way to determine platform_version in a rolling release distribution # kernel release will be used - ex. 2.6.32-ARCH platform_version `uname -r`.strip - elsif File.exist?('/etc/exherbo-release') + elsif File.exist?("/etc/exherbo-release") platform "exherbo" # no way to determine platform_version in a rolling release distribution # kernel release will be used - ex. 3.13 platform_version `uname -r`.strip - elsif File.exist?('/etc/alpine-release') + elsif File.exist?("/etc/alpine-release") platform "alpine" platform_version File.read("/etc/alpine-release").strip() elsif os_release_file_is_cisco? - raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field' if - os_release_info['ID_LIKE'].nil? || ! os_release_info['ID_LIKE'].include?('wrlinux') + raise "unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field" if + os_release_info["ID_LIKE"].nil? || ! os_release_info["ID_LIKE"].include?("wrlinux") - case os_release_info['ID'] - when 'nexus' - platform 'nexus' - when 'ios_xr' - platform 'ios_xr' + case os_release_info["ID"] + when "nexus" + platform "nexus" + when "ios_xr" + platform "ios_xr" else - raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID field' + raise "unknown Cisco /etc/os-release or /etc/cisco-release ID field" end - platform_family 'wrlinux' - platform_version os_release_info['VERSION'] + platform_family "wrlinux" + platform_version os_release_info["VERSION"] elsif lsb[:id] =~ /RedHat/i platform "redhat" platform_version lsb[:release] diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb index f3182974..d681bc5d 100644 --- a/lib/ohai/plugins/linux/virtualization.rb +++ b/lib/ohai/plugins/linux/virtualization.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'ohai/util/file_helper' -require 'ohai/mixin/dmi_decode' +require "ohai/util/file_helper" +require "ohai/mixin/dmi_decode" include Ohai::Util::FileHelper include Ohai::Mixin::DmiDecode @@ -26,11 +26,11 @@ Ohai.plugin(:Virtualization) do provides "virtualization" def lxc_version_exists? - which('lxc-version') + which("lxc-version") end def docker_exists? - which('docker') + which("docker") end collect_data(:linux) do @@ -118,11 +118,11 @@ Ohai.plugin(:Virtualization) do # parse dmidecode to discover various virtualization guests if File.exist?("/usr/sbin/dmidecode") - guest = guest_from_dmi(shell_out('dmidecode').stdout) + guest = guest_from_dmi(shell_out("dmidecode").stdout) if guest virtualization[:system] = guest - virtualization[:role] = 'guest' - virtualization[:systems][guest.to_sym] = 'guest' + virtualization[:role] = "guest" + virtualization[:systems][guest.to_sym] = "guest" end end diff --git a/lib/ohai/plugins/mono.rb b/lib/ohai/plugins/mono.rb index 8a458bf1..9254924b 100644 --- a/lib/ohai/plugins/mono.rb +++ b/lib/ohai/plugins/mono.rb @@ -33,7 +33,7 @@ Ohai.plugin(:Mono) do mono[:version] = output[4] end if output.length >= 11 - mono[:builddate] = "%s %s %s %s" % [output[6],output[7],output[8],output[11].gsub!(/\)/,'')] + mono[:builddate] = "%s %s %s %s" % [output[6], output[7], output[8], output[11].gsub!(/\)/, "")] end languages[:mono] = mono if mono[:version] end diff --git a/lib/ohai/plugins/netbsd/cpu.rb b/lib/ohai/plugins/netbsd/cpu.rb index 1b0a2667..4a2f85a0 100644 --- a/lib/ohai/plugins/netbsd/cpu.rb +++ b/lib/ohai/plugins/netbsd/cpu.rb @@ -17,7 +17,7 @@ # Ohai.plugin(:CPU) do - provides 'cpu' + provides "cpu" collect_data(:netbsd) do cpuinfo = Mash.new diff --git a/lib/ohai/plugins/netbsd/network.rb b/lib/ohai/plugins/netbsd/network.rb index 8f0cff56..f2b8f85f 100644 --- a/lib/ohai/plugins/netbsd/network.rb +++ b/lib/ohai/plugins/netbsd/network.rb @@ -58,7 +58,7 @@ Ohai.plugin(:Network) do if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] # convert the netmask to decimal for consistency - netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}" + netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}" if $3.empty? iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask } else @@ -76,7 +76,7 @@ Ohai.plugin(:Network) do end end if line =~ /flags=\d+<(.+)>/ - flags = $1.split(',') + flags = $1.split(",") iface[cint][:flags] = flags if flags.length > 0 end if line =~ /metric: (\d+) mtu: (\d+)/ diff --git a/lib/ohai/plugins/network.rb b/lib/ohai/plugins/network.rb index 4b6f8202..caa3e840 100644 --- a/lib/ohai/plugins/network.rb +++ b/lib/ohai/plugins/network.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'ipaddress' -require 'ohai/mixin/network_constants' +require "ipaddress" +require "ohai/mixin/network_constants" Ohai.plugin(:NetworkAddresses) do include Ohai::Mixin::NetworkConstants @@ -29,21 +29,21 @@ Ohai.plugin(:NetworkAddresses) do # from interface data create array of hashes with ipaddress, scope, and iface # sorted by scope, prefixlen and then ipaddress where longest prefixes first def sorted_ips(family = "inet") - fail "bad family #{family}" unless %w(inet inet6).include? family + raise "bad family #{family}" unless %w{inet inet6}.include? family # priority of ipv6 link scopes to sort by later scope_prio = [ "global", "site", "link", "host", "node", nil ] # grab ipaddress, scope, and iface for sorting later ipaddresses = [] - Mash[network['interfaces']].each do |iface, iface_v| - next if iface_v.nil? || !iface_v.has_key?('addresses') - iface_v['addresses'].each do |addr, addr_v| - next if addr_v.nil? or not addr_v.has_key? "family" or addr_v['family'] != family + Mash[network["interfaces"]].each do |iface, iface_v| + next if iface_v.nil? || !iface_v.has_key?("addresses") + iface_v["addresses"].each do |addr, addr_v| + next if addr_v.nil? or not addr_v.has_key? "family" or addr_v["family"] != family ipaddresses << { :ipaddress => addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"), :scope => addr_v["scope"].nil? ? nil : addr_v["scope"].downcase, - :iface => iface + :iface => iface, } end end @@ -53,7 +53,7 @@ Ohai.plugin(:NetworkAddresses) do ipaddresses.sort_by do |v| [ ( scope_prio.index(v[:scope]) || 999999 ), 128 - v[:ipaddress].prefix.to_i, - ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 ) + ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 ), ] end end @@ -68,7 +68,7 @@ Ohai.plugin(:NetworkAddresses) do return [ nil, nil ] if ips.empty? # shortcuts to access default #{family} interface and gateway - int_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] +"_interface" + int_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] + "_interface" gw_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] + "_gateway" if network[int_attr] @@ -79,8 +79,8 @@ Ohai.plugin(:NetworkAddresses) do if gw_if_ips.empty? Ohai::Log.warn("[#{family}] no ip address on #{network[int_attr]}") elsif network[gw_attr] && - network["interfaces"][network[int_attr]] && - network["interfaces"][network[int_attr]]["addresses"] + network["interfaces"][network[int_attr]] && + network["interfaces"][network[int_attr]]["addresses"] if [ "0.0.0.0", "::", /^fe80:/ ].any? { |pat| pat === network[gw_attr] } # link level default route Ohai::Log.debug("link level default #{family} route, picking ip from #{network[gw_attr]}") @@ -113,7 +113,7 @@ Ohai.plugin(:NetworkAddresses) do # select mac address of first interface with family of lladdr def find_mac_from_iface(iface) - r = network["interfaces"][iface]["addresses"].select{|k,v| v["family"] == "lladdr"} + r = network["interfaces"][iface]["addresses"].select { |k, v| v["family"] == "lladdr" } r.nil? || r.first.nil? ? nil : r.first.first end @@ -176,7 +176,7 @@ Ohai.plugin(:NetworkAddresses) do end if results["inet"]["iface"] && results["inet6"]["iface"] && - (results["inet"]["iface"] != results["inet6"]["iface"]) + (results["inet"]["iface"] != results["inet6"]["iface"]) Ohai::Log.debug("ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})") end end diff --git a/lib/ohai/plugins/network_listeners.rb b/lib/ohai/plugins/network_listeners.rb index 3b6b9479..7ecfef72 100644 --- a/lib/ohai/plugins/network_listeners.rb +++ b/lib/ohai/plugins/network_listeners.rb @@ -22,8 +22,8 @@ Ohai.plugin(:NetworkListeners) do depends "network", "counters/network" collect_data do - require 'sigar' - flags = Sigar::NETCONN_TCP|Sigar::NETCONN_SERVER + require "sigar" + flags = Sigar::NETCONN_TCP | Sigar::NETCONN_SERVER network Mash.new unless network listeners = Mash.new diff --git a/lib/ohai/plugins/ohai.rb b/lib/ohai/plugins/ohai.rb index ca01e21e..9cadb480 100644 --- a/lib/ohai/plugins/ohai.rb +++ b/lib/ohai/plugins/ohai.rb @@ -6,9 +6,9 @@ # 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. @@ -20,7 +20,7 @@ Ohai.plugin(:Ohai) do provides "chef_packages/ohai" collect_data do - require 'ohai' + require "ohai" chef_packages Mash.new unless chef_packages chef_packages[:ohai] = Mash.new diff --git a/lib/ohai/plugins/openbsd/cpu.rb b/lib/ohai/plugins/openbsd/cpu.rb index 91af3fe6..e106b540 100644 --- a/lib/ohai/plugins/openbsd/cpu.rb +++ b/lib/ohai/plugins/openbsd/cpu.rb @@ -17,19 +17,19 @@ # Ohai.plugin(:CPU) do - provides 'cpu' + provides "cpu" collect_data(:openbsd) do cpuinfo = Mash.new - # OpenBSD provides most cpu information via sysctl, the only thing we need to - # to scrape from dmesg.boot is the cpu feature list. + # OpenBSD provides most cpu information via sysctl, the only thing we need to + # to scrape from dmesg.boot is the cpu feature list. # cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2 File.open("/var/run/dmesg.boot").each do |line| case line when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/ - cpuinfo["flags"] = $1.downcase.split(',') + cpuinfo["flags"] = $1.downcase.split(",") end end diff --git a/lib/ohai/plugins/openbsd/memory.rb b/lib/ohai/plugins/openbsd/memory.rb index 3ad60fbc..020a3881 100644 --- a/lib/ohai/plugins/openbsd/memory.rb +++ b/lib/ohai/plugins/openbsd/memory.rb @@ -71,13 +71,13 @@ Ohai.plugin(:Memory) do memory[:page_count] = $1 memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i when /(\d+) pages free/ - memory[:free] = memory[:page_size].to_i * $1.to_i + memory[:free] = memory[:page_size].to_i * $1.to_i when /(\d+) pages active/ - memory[:active] = memory[:page_size].to_i * $1.to_i + memory[:active] = memory[:page_size].to_i * $1.to_i when /(\d+) pages inactive/ - memory[:inactive] = memory[:page_size].to_i * $1.to_i + memory[:inactive] = memory[:page_size].to_i * $1.to_i when /(\d+) pages wired/ - memory[:wired] = memory[:page_size].to_i * $1.to_i + memory[:wired] = memory[:page_size].to_i * $1.to_i end end diff --git a/lib/ohai/plugins/openbsd/network.rb b/lib/ohai/plugins/openbsd/network.rb index a19c4f1e..4bcdc19d 100644 --- a/lib/ohai/plugins/openbsd/network.rb +++ b/lib/ohai/plugins/openbsd/network.rb @@ -58,7 +58,7 @@ Ohai.plugin(:Network) do if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] # convert the netmask to decimal for consistency - netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}" + netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}" if $3.empty? iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask } else @@ -76,7 +76,7 @@ Ohai.plugin(:Network) do end end if line =~ /flags=\d+<(.+)>/ - flags = $1.split(',') + flags = $1.split(",") iface[cint][:flags] = flags if flags.length > 0 end if line =~ /metric: (\d+) mtu: (\d+)/ @@ -100,7 +100,7 @@ Ohai.plugin(:Network) do # From netstat(1), not sure of the implications: # Show the state of all network interfaces or a single interface # which have been auto-configured (interfaces statically configured - # into a system, but not located at boot time are not shown). + # into a system, but not located at boot time are not shown). so = shell_out("netstat -idn") so.stdout.lines do |line| # Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb index 305b7cb7..b7ac8973 100644 --- a/lib/ohai/plugins/openstack.rb +++ b/lib/ohai/plugins/openstack.rb @@ -15,22 +15,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/mixin/ec2_metadata' +require "ohai/mixin/ec2_metadata" Ohai.plugin(:Openstack) do provides "openstack" include Ohai::Mixin::Ec2Metadata - def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = '2013-04-04') + def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = "2013-04-04") path = "/openstack/#{api_version}/meta_data.json" uri = "http://#{addr}#{path}" begin - response = http_client.get_response(URI.parse(uri),nil,nil) + response = http_client.get_response(URI.parse(uri), nil, nil) case response.code - when '200' + when "200" FFI_Yajl::Parser.parse(response.body) - when '404' + when "404" Ohai::Log.debug("Encountered 404 response retreiving OpenStack specific metadata path: #{path} ; continuing.") nil else @@ -44,20 +44,20 @@ Ohai.plugin(:Openstack) do collect_data do # Adds openstack Mash - if hint?('openstack') || hint?('hp') + if hint?("openstack") || hint?("hp") Ohai::Log.debug("ohai openstack") - if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80) + if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80) openstack Mash.new Ohai::Log.debug("connecting to the OpenStack metadata service") - fetch_metadata.each {|k, v| openstack[k] = v } + fetch_metadata.each { |k, v| openstack[k] = v } - if hint?('hp') - openstack['provider'] = 'hp' + if hint?("hp") + openstack["provider"] = "hp" else - openstack['provider'] = 'openstack' + openstack["provider"] = "openstack" Ohai::Log.debug("connecting to the OpenStack specific metadata service") - openstack['metadata'] = collect_openstack_metadata + openstack["metadata"] = collect_openstack_metadata end else diff --git a/lib/ohai/plugins/os.rb b/lib/ohai/plugins/os.rb index 13493e37..2016ff68 100644 --- a/lib/ohai/plugins/os.rb +++ b/lib/ohai/plugins/os.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'ohai/mixin/os' +require "ohai/mixin/os" Ohai.plugin(:OS) do provides "os", "os_version" - depends 'kernel' + depends "kernel" collect_data do os collect_os diff --git a/lib/ohai/plugins/packages.rb b/lib/ohai/plugins/packages.rb index 95b6955f..b9d06451 100644 --- a/lib/ohai/plugins/packages.rb +++ b/lib/ohai/plugins/packages.rb @@ -19,30 +19,30 @@ # # Ohai.plugin(:Packages) do - provides 'packages' - depends 'platform_family' + provides "packages" + depends "platform_family" collect_data(:linux) do if configuration(:enabled) packages Mash.new - if %w(debian).include? platform_family - so = shell_out('dpkg-query -W') + if %w{debian}.include? platform_family + so = shell_out("dpkg-query -W") pkgs = so.stdout.lines pkgs.each do |pkg| name, version = pkg.split - packages[name] = { 'version' => version } + packages[name] = { "version" => version } end - elsif %w(rhel fedora suse).include? platform_family - require 'shellwords' + elsif %w{rhel fedora suse}.include? platform_family + require "shellwords" format = Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n' so = shell_out("rpm -qa --queryformat #{format}") pkgs = so.stdout.lines pkgs.each do |pkg| name, version, release = pkg.split - packages[name] = { 'version' => version, 'release' => release } + packages[name] = { "version" => version, "release" => release } end end end @@ -51,15 +51,15 @@ Ohai.plugin(:Packages) do collect_data(:windows) do if configuration(:enabled) packages Mash.new - require 'wmi-lite' + require "wmi-lite" wmi = WmiLite::Wmi.new - w32_product = wmi.instances_of('Win32_Product') + w32_product = wmi.instances_of("Win32_Product") w32_product.find_all.each do |product| - name = product['name'] + name = product["name"] package = packages[name] = Mash.new - %w(version vendor installdate).each do |attr| + %w{version vendor installdate}.each do |attr| package[attr] = product[attr] end end @@ -69,21 +69,21 @@ Ohai.plugin(:Packages) do collect_data(:aix) do if configuration(:enabled) packages Mash.new - so = shell_out('lslpp -L -q -c') + so = shell_out("lslpp -L -q -c") pkgs = so.stdout.lines # Output format is # Package Name:Fileset:Level # On aix, filesets are packages and levels are versions pkgs.each do |pkg| - _, name, version = pkg.split(':') - packages[name] = { 'version' => version } + _, name, version = pkg.split(":") + packages[name] = { "version" => version } end end end def collect_ips_packages - so = shell_out('pkg list -H') + so = shell_out("pkg list -H") # Output format is # NAME (PUBLISHER) VERSION IFO so.stdout.lines.each do |pkg| @@ -94,13 +94,13 @@ Ohai.plugin(:Packages) do name, publisher, version, = tokens publisher = publisher[1..-2] end - packages[name] = { 'version' => version } - packages[name]['publisher'] = publisher if publisher + packages[name] = { "version" => version } + packages[name]["publisher"] = publisher if publisher end end def collect_sysv_packages - so = shell_out('pkginfo -l') + so = shell_out("pkginfo -l") # Each package info is separated by a blank line chunked_lines = so.stdout.lines.map(&:strip).chunk do |line| !line.empty? || nil @@ -108,12 +108,12 @@ Ohai.plugin(:Packages) do chunked_lines.each do |_, lines| package = {} lines.each do |line| - key, value = line.split(':', 2) + key, value = line.split(":", 2) package[key.strip.downcase] = value.strip unless value.nil? end # pkginst is the installed package name - packages[package['pkginst']] = package.tap do |p| - p.delete('pkginst') + packages[package["pkginst"]] = package.tap do |p| + p.delete("pkginst") end end end diff --git a/lib/ohai/plugins/passwd.rb b/lib/ohai/plugins/passwd.rb index 675a70b8..0775efe3 100644 --- a/lib/ohai/plugins/passwd.rb +++ b/lib/ohai/plugins/passwd.rb @@ -1,8 +1,8 @@ -require 'etc' +require "etc" Ohai.plugin(:Passwd) do - provides 'etc', 'current_user' + provides "etc", "current_user" def fix_encoding(str) str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding) @@ -18,14 +18,14 @@ Ohai.plugin(:Passwd) do Etc.passwd do |entry| user_passwd_entry = Mash.new(:dir => entry.dir, :gid => entry.gid, :uid => entry.uid, :shell => entry.shell, :gecos => entry.gecos) - user_passwd_entry.each_value {|v| fix_encoding(v)} + user_passwd_entry.each_value { |v| fix_encoding(v) } entry_name = fix_encoding(entry.name) etc[:passwd][entry_name] = user_passwd_entry unless etc[:passwd].has_key?(entry_name) end Etc.group do |entry| group_entry = Mash.new(:gid => entry.gid, - :members => entry.mem.map {|u| fix_encoding(u)}) + :members => entry.mem.map { |u| fix_encoding(u) }) etc[:group][fix_encoding(entry.name)] = group_entry end diff --git a/lib/ohai/plugins/powershell.rb b/lib/ohai/plugins/powershell.rb index 79eadb82..bf315806 100644 --- a/lib/ohai/plugins/powershell.rb +++ b/lib/ohai/plugins/powershell.rb @@ -40,21 +40,21 @@ Ohai.plugin(:Powershell) do kv = line.strip.split(/\s+/, 2) version_info[kv[0]] = kv[1] if kv.length == 2 end - powershell[:version] = version_info['PSVersion'] - powershell[:ws_man_stack_version] = version_info['WSManStackVersion'] - powershell[:serialization_version] = version_info['SerializationVersion'] - powershell[:clr_version] = version_info['CLRVersion'] - powershell[:build_version] = version_info['BuildVersion'] - powershell[:compatible_versions] = parse_compatible_versions(version_info['PSCompatibleVersions']) - powershell[:remoting_protocol_version] = version_info['PSRemotingProtocolVersion'] + powershell[:version] = version_info["PSVersion"] + powershell[:ws_man_stack_version] = version_info["WSManStackVersion"] + powershell[:serialization_version] = version_info["SerializationVersion"] + powershell[:clr_version] = version_info["CLRVersion"] + powershell[:build_version] = version_info["BuildVersion"] + powershell[:compatible_versions] = parse_compatible_versions(version_info["PSCompatibleVersions"]) + powershell[:remoting_protocol_version] = version_info["PSRemotingProtocolVersion"] languages[:powershell] = powershell if powershell[:version] end end def parse_compatible_versions(versions_str) if versions_str - if versions_str.strip.start_with?('{') && versions_str.end_with?('}') - versions = versions_str.gsub(/[{}\s]+/,'').split(',') + if versions_str.strip.start_with?("{") && versions_str.end_with?("}") + versions = versions_str.gsub(/[{}\s]+/, "").split(",") versions if versions.length end end diff --git a/lib/ohai/plugins/ps.rb b/lib/ohai/plugins/ps.rb index 2232e781..5edd3bb8 100644 --- a/lib/ohai/plugins/ps.rb +++ b/lib/ohai/plugins/ps.rb @@ -24,11 +24,11 @@ Ohai.plugin(:PS) do depends "command" collect_data(:aix, :darwin, :hpux, :linux, :solaris2) do - command[:ps] = 'ps -ef' + command[:ps] = "ps -ef" end collect_data(:freebsd, :netbsd, :openbsd, :dragonflybsd) do # ps -e requires procfs - command[:ps] = 'ps -axww' + command[:ps] = "ps -axww" end end diff --git a/lib/ohai/plugins/python.rb b/lib/ohai/plugins/python.rb index bb93d0ea..e493421c 100644 --- a/lib/ohai/plugins/python.rb +++ b/lib/ohai/plugins/python.rb @@ -32,7 +32,7 @@ Ohai.plugin(:Python) do output = so.stdout.split python[:version] = output[0] if output.length >= 6 - python[:builddate] = "%s %s %s %s" % [output[2],output[3],output[4],output[5].gsub!(/\)/,'')] + python[:builddate] = "%s %s %s %s" % [output[2], output[3], output[4], output[5].gsub!(/\)/, "")] end languages[:python] = python if python[:version] and python[:builddate] diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb index 7aa02b2d..18a6216e 100644 --- a/lib/ohai/plugins/rackspace.rb +++ b/lib/ohai/plugins/rackspace.rb @@ -27,7 +27,7 @@ Ohai.plugin(:Rackspace) do # true:: If kernel name matches # false:: Otherwise def has_rackspace_kernel? - kernel[:release].split('-').last.eql?("rscloud") + kernel[:release].split("-").last.eql?("rscloud") end # Checks for rackspace provider attribute @@ -38,7 +38,7 @@ Ohai.plugin(:Rackspace) do def has_rackspace_metadata? so = shell_out("xenstore-read vm-data/provider_data/provider") if so.exitstatus == 0 - so.stdout.strip.downcase == 'rackspace' + so.stdout.strip.downcase == "rackspace" end rescue Errno::ENOENT false @@ -50,7 +50,7 @@ Ohai.plugin(:Rackspace) do # true:: If the rackspace cloud can be identified # false:: Otherwise def looks_like_rackspace? - hint?('rackspace') || has_rackspace_metadata? || has_rackspace_kernel? + hint?("rackspace") || has_rackspace_metadata? || has_rackspace_kernel? end # Names rackspace ip address @@ -60,7 +60,7 @@ Ohai.plugin(:Rackspace) do # eth:: Interface name of public or private ip def get_ip_address(name, eth) network[:interfaces][eth][:addresses].each do |key, info| - if info['family'] == 'inet' + if info["family"] == "inet" rackspace[name] = key break # break when we found an address end @@ -75,7 +75,7 @@ Ohai.plugin(:Rackspace) do def get_global_ipv6_address(name, eth) network[:interfaces][eth][:addresses].each do |key, info| # check if we got an ipv6 address and if its in global scope - if info['family'] == 'inet6' && info['scope'] == 'Global' + if info["family"] == "inet6" && info["scope"] == "Global" rackspace[name] = key break # break when we found an address end @@ -111,24 +111,24 @@ Ohai.plugin(:Rackspace) do # Get the rackspace private networks # def get_private_networks() - so = shell_out('xenstore-ls vm-data/networking') + so = shell_out("xenstore-ls vm-data/networking") if so.exitstatus == 0 networks = [] - so.stdout.split("\n").map{|l| l.split('=').first.strip }.map do |item| + so.stdout.split("\n").map { |l| l.split("=").first.strip }.map do |item| _so = shell_out("xenstore-read vm-data/networking/#{item}") if _so.exitstatus == 0 networks.push(FFI_Yajl::Parser.new.parse(_so.stdout)) else - Ohai::Log.debug('rackspace plugin: Unable to capture custom private networking information for Rackspace cloud') + Ohai::Log.debug("rackspace plugin: Unable to capture custom private networking information for Rackspace cloud") return false end end # these networks are already known to ohai, and are not 'private networks' - networks.delete_if { |hash| hash['label'] == 'private' } - networks.delete_if { |hash| hash['label'] == 'public' } + networks.delete_if { |hash| hash["label"] == "private" } + networks.delete_if { |hash| hash["label"] == "public" } end rescue Errno::ENOENT - Ohai::Log.debug('rackspace plugin: Unable to capture custom private networking information for Rackspace cloud') + Ohai::Log.debug("rackspace plugin: Unable to capture custom private networking information for Rackspace cloud") nil end diff --git a/lib/ohai/plugins/root_group.rb b/lib/ohai/plugins/root_group.rb index 51fb9a4b..c6f2605d 100644 --- a/lib/ohai/plugins/root_group.rb +++ b/lib/ohai/plugins/root_group.rb @@ -16,17 +16,17 @@ # limitations under the License. Ohai.plugin(:RootGroup) do - provides 'root_group' + provides "root_group" - require 'ohai/util/win32/group_helper' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + require "ohai/util/win32/group_helper" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ collect_data do - case ::RbConfig::CONFIG['host_os'] + case ::RbConfig::CONFIG["host_os"] when /mswin|mingw32|windows/ group = Ohai::Util::Win32::GroupHelper.windows_root_group_name root_group group else - root_group Etc.getgrgid(Etc.getpwnam('root').gid).name + root_group Etc.getgrgid(Etc.getpwnam("root").gid).name end end end diff --git a/lib/ohai/plugins/ruby.rb b/lib/ohai/plugins/ruby.rb index d3116da9..a378855c 100644 --- a/lib/ohai/plugins/ruby.rb +++ b/lib/ohai/plugins/ruby.rb @@ -43,7 +43,7 @@ Ohai.plugin(:Ruby) do :host_os => "RbConfig::CONFIG['host_os']", :host_vendor => "RbConfig::CONFIG['host_vendor']", :bin_dir => "RbConfig::CONFIG['bindir']", - :ruby_bin => "::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])" + :ruby_bin => "::File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])", } # Create a query string from above hash @@ -56,8 +56,8 @@ Ohai.plugin(:Ruby) do result = run_ruby "puts %Q(#{env_string})" # Parse results to plugin hash - result.split(',').each do |entry| - key, value = entry.split('=') + result.split(",").each do |entry| + key, value = entry.split("=") languages[:ruby][key.to_sym] = value || "" end @@ -66,9 +66,9 @@ Ohai.plugin(:Ruby) do ruby_bin = languages[:ruby][:ruby_bin] gem_binaries = [ run_ruby("require 'rubygems'; puts ::Gem.default_exec_format % 'gem'"), - "gem" - ].map {|bin| ::File.join(bin_dir, bin)} - gem_binary = gem_binaries.find {|bin| ::File.exists? bin } + "gem", + ].map { |bin| ::File.join(bin_dir, bin) } + gem_binary = gem_binaries.find { |bin| ::File.exists? bin } if gem_binary languages[:ruby][:gems_dir] = run_ruby "puts %x{#{ruby_bin} #{gem_binary} env gemdir}.chomp!" languages[:ruby][:gem_bin] = gem_binary diff --git a/lib/ohai/plugins/rust.rb b/lib/ohai/plugins/rust.rb index 9e65a3fa..f268d9cb 100644 --- a/lib/ohai/plugins/rust.rb +++ b/lib/ohai/plugins/rust.rb @@ -24,7 +24,7 @@ Ohai.plugin(:Rust) do rust = Mash.new so = shell_out("rustc --version") if so.exitstatus == 0 - output = so.stdout.split + output = so.stdout.split rust[:version] = output[1] languages[:rust] = rust if rust[:version] end diff --git a/lib/ohai/plugins/sigar/cpu.rb b/lib/ohai/plugins/sigar/cpu.rb index a5bcc73f..54f8387c 100644 --- a/lib/ohai/plugins/sigar/cpu.rb +++ b/lib/ohai/plugins/sigar/cpu.rb @@ -20,7 +20,7 @@ Ohai.plugin(:CPU) do provides "cpu" collect_data(:hpux, :default) do - require 'sigar' + require "sigar" sigar = Sigar.new diff --git a/lib/ohai/plugins/sigar/filesystem.rb b/lib/ohai/plugins/sigar/filesystem.rb index a01c379e..234fc16f 100644 --- a/lib/ohai/plugins/sigar/filesystem.rb +++ b/lib/ohai/plugins/sigar/filesystem.rb @@ -36,7 +36,7 @@ Ohai.plugin(:Filesystem) do fs[filesystem][:kb_size] = (usage.total / 1024).to_s fs[filesystem][:kb_used] = ((usage.total - usage.free) / 1024).to_s fs[filesystem][:kb_available] = (usage.free / 1024).to_s - fs[filesystem][:percent_used] = (usage.use_percent * 100).to_s + '%' + fs[filesystem][:percent_used] = (usage.use_percent * 100).to_s + "%" rescue SystemExit => e raise rescue Exception => e diff --git a/lib/ohai/plugins/sigar/network.rb b/lib/ohai/plugins/sigar/network.rb index 36cf581b..d5bfa52d 100644 --- a/lib/ohai/plugins/sigar/network.rb +++ b/lib/ohai/plugins/sigar/network.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'ohai/mixin/network_constants' +require "ohai/mixin/network_constants" Ohai.plugin(:Network) do include Ohai::Mixin::NetworkConstants @@ -57,8 +57,8 @@ Ohai.plugin(:Network) do if ifconfig.address != "0.0.0.0" iface[cint][:addresses][ifconfig.address] = { "family" => "inet" } # Backwards compat: no broadcast on tunnel or loopback dev - if (((ifconfig.flags & Sigar::IFF_POINTOPOINT) == 0) && - ((ifconfig.flags & Sigar::IFF_LOOPBACK) == 0)) + if ((ifconfig.flags & Sigar::IFF_POINTOPOINT) == 0) && + ((ifconfig.flags & Sigar::IFF_LOOPBACK) == 0) iface[cint][:addresses][ifconfig.address]["broadcast"] = ifconfig.broadcast end iface[cint][:addresses][ifconfig.address]["netmask"] = ifconfig.netmask @@ -70,20 +70,20 @@ Ohai.plugin(:Network) do iface[cint][:addresses][ifconfig.address6]["scope"] = Sigar.net_scope_to_s(ifconfig.scope6) end - iface[cint][:flags] = Sigar.net_interface_flags_to_s(ifconfig.flags).split(' ') + iface[cint][:flags] = Sigar.net_interface_flags_to_s(ifconfig.flags).split(" ") iface[cint][:mtu] = ifconfig.mtu.to_s iface[cint][:queuelen] = ifconfig.tx_queue_len.to_s net_counters[cint] = Mash.new unless net_counters[cint] - if (!cint.include?(":")) + if !cint.include?(":") ifstat = sigar.net_interface_stat(cint) net_counters[cint][:rx] = { "packets" => ifstat.rx_packets.to_s, "errors" => ifstat.rx_errors.to_s, - "drop" => ifstat.rx_dropped.to_s, "overrun" => ifstat.rx_overruns.to_s, - "frame" => ifstat.rx_frame.to_s, "bytes" => ifstat.rx_bytes.to_s } + "drop" => ifstat.rx_dropped.to_s, "overrun" => ifstat.rx_overruns.to_s, + "frame" => ifstat.rx_frame.to_s, "bytes" => ifstat.rx_bytes.to_s } net_counters[cint][:tx] = { "packets" => ifstat.tx_packets.to_s, "errors" => ifstat.tx_errors.to_s, - "drop" => ifstat.tx_dropped.to_s, "overrun" => ifstat.tx_overruns.to_s, - "carrier" => ifstat.tx_carrier.to_s, "collisions" => ifstat.tx_collisions.to_s, - "bytes" => ifstat.tx_bytes.to_s } + "drop" => ifstat.tx_dropped.to_s, "overrun" => ifstat.tx_overruns.to_s, + "carrier" => ifstat.tx_carrier.to_s, "collisions" => ifstat.tx_collisions.to_s, + "bytes" => ifstat.tx_bytes.to_s } end end @@ -154,12 +154,12 @@ Ohai.plugin(:Network) do next unless network[:interfaces][route.ifname] # this # should never happen network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route] - route_data={} + route_data = {} Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m| if(m == :flags) - route_data[m]=flags(route.send(m)) + route_data[m] = flags(route.send(m)) else - route_data[m]=route.send(m) + route_data[m] = route.send(m) end end network[:interfaces][route.ifname][:route][route.destination] = route_data diff --git a/lib/ohai/plugins/sigar/network_route.rb b/lib/ohai/plugins/sigar/network_route.rb index 0275e5a5..eaed4052 100644 --- a/lib/ohai/plugins/sigar/network_route.rb +++ b/lib/ohai/plugins/sigar/network_route.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'ohai/mixin/network_constants' +require "ohai/mixin/network_constants" Ohai.plugin(:NetworkRoutes) do include Ohai::Mixin::NetworkConstants @@ -45,12 +45,12 @@ Ohai.plugin(:NetworkRoutes) do sigar.net_route_list.each do |route| next unless network[:interfaces][route.ifname] # this should never happen network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route] - route_data={} + route_data = {} Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m| if(m == :flags) - route_data[m]=flags(route.send(m)) + route_data[m] = flags(route.send(m)) else - route_data[m]=route.send(m) + route_data[m] = route.send(m) end end network[:interfaces][route.ifname][:route][route.destination] = route_data diff --git a/lib/ohai/plugins/softlayer.rb b/lib/ohai/plugins/softlayer.rb index 4704e0a6..528d0785 100644 --- a/lib/ohai/plugins/softlayer.rb +++ b/lib/ohai/plugins/softlayer.rb @@ -18,12 +18,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/mixin/softlayer_metadata' +require "ohai/mixin/softlayer_metadata" Ohai.plugin(:Softlayer) do include ::Ohai::Mixin::SoftlayerMetadata - provides 'softlayer' + provides "softlayer" # Identifies the softlayer cloud # @@ -31,7 +31,7 @@ Ohai.plugin(:Softlayer) do # true:: If the softlayer cloud can be identified # false:: Otherwise def looks_like_softlayer? - hint?('softlayer') + hint?("softlayer") end collect_data do @@ -40,7 +40,7 @@ Ohai.plugin(:Softlayer) do Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == true") metadata = fetch_metadata softlayer Mash.new - metadata.each { |k,v| softlayer[k] = v } if metadata + metadata.each { |k, v| softlayer[k] = v } if metadata else Ohai::Log.debug("softlayer plugin: looks_like_softlayer? == false") end diff --git a/lib/ohai/plugins/solaris2/cpu.rb b/lib/ohai/plugins/solaris2/cpu.rb index a403940e..4a60318e 100644 --- a/lib/ohai/plugins/solaris2/cpu.rb +++ b/lib/ohai/plugins/solaris2/cpu.rb @@ -16,13 +16,13 @@ Ohai.plugin(:CPU) do provides "cpu" - + collect_data(:solaris2) do cpu Mash.new # This does assume that /usr/bin/kstat is in the path processor_info = shell_out("kstat -p cpu_info").stdout.lines - cpu["total"] = 0 - cpu["sockets"] = 0 + cpu["total"] = 0 + cpu["sockets"] = 0 cpu["cores"] = 0 cpu["corethreads"] = 0 cpu["cpustates"] = Mash.new @@ -31,35 +31,35 @@ Ohai.plugin(:CPU) do cpucores = Array.new cpusockets = Array.new processor_info.each_with_index do |processor, i| - desc,instance,record,keyvalue = processor.split(":") + desc, instance, record, keyvalue = processor.split(":") cpu[instance] ||= Mash.new - if (currentcpu != instance) - cpu["total"] += 1 - currentcpu = instance - end + if (currentcpu != instance) + cpu["total"] += 1 + currentcpu = instance + end kv = keyvalue.split(/\s+/) key = kv.shift value = kv.join(" ").chomp case key when /chip_id/ - cpu[instance]["socket"] = value - cpusockets.push(value) if cpusockets.index(value).nil? + cpu[instance]["socket"] = value + cpusockets.push(value) if cpusockets.index(value).nil? when /cpu_type/ - cpu[instance]["arch"] = value + cpu[instance]["arch"] = value when /clock_MHz/ - cpu[instance]["mhz"] = value + cpu[instance]["mhz"] = value when /brand/ - cpu[instance]["model_name"] = value.sub(/\s+/," ") + cpu[instance]["model_name"] = value.sub(/\s+/, " ") when /^state$/ - cpu[instance]["state"] = value - cpu["cpustates"][value] ||= 0 - cpu["cpustates"][value] += 1 + cpu[instance]["state"] = value + cpu["cpustates"][value] ||= 0 + cpu["cpustates"][value] += 1 when /core_id/ - cpu[instance]["core_id"] = value + cpu[instance]["core_id"] = value # Detect hyperthreading/multithreading - cpucores.push(value) if cpucores.index(value).nil? + cpucores.push(value) if cpucores.index(value).nil? when /family|fpu_type|model|stepping|vendor_id/ - cpu[instance][key] = value + cpu[instance][key] = value end end cpu["cores"] = cpucores.size diff --git a/lib/ohai/plugins/solaris2/dmi.rb b/lib/ohai/plugins/solaris2/dmi.rb index 71b3367f..f4d8cc3c 100644 --- a/lib/ohai/plugins/solaris2/dmi.rb +++ b/lib/ohai/plugins/solaris2/dmi.rb @@ -6,9 +6,9 @@ # 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. @@ -20,72 +20,72 @@ Ohai.plugin(:DMI) do provides "dmi" collect_data(:solaris2) do - require 'ohai/common/dmi' + require "ohai/common/dmi" # if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios # note that a single key just means dmidecode exited with its version - if (dmi.class.to_s == 'Mash') and (dmi.keys.length > 1) - Ohai::Log.debug('skipping smbios output, since DMI information has already been provided') + if (dmi.class.to_s == "Mash") and (dmi.keys.length > 1) + Ohai::Log.debug("skipping smbios output, since DMI information has already been provided") return end dmi Mash.new - # bad Solaris shows strings defined by system instead of SMB IDs + # bad Solaris shows strings defined by system instead of SMB IDs # this is what the *real* IDs are: # pulled from http://src.opensolaris.org/source/xref/nwam/nwam1/usr/src/uts/common/sys/smbios.h smb_to_id = { - 'SMB_TYPE_BIOS' => 0, # BIOS information (R) - 'SMB_TYPE_SYSTEM' => 1, # system information (R) - 'SMB_TYPE_BASEBOARD' => 2, # base board - 'SMB_TYPE_CHASSIS' => 3, # system enclosure or chassis (R) - 'SMB_TYPE_PROCESSOR' => 4, # processor (R) - 'SMB_TYPE_MEMCTL' => 5, # memory controller (O) - 'SMB_TYPE_MEMMOD' => 6, # memory module (O) - 'SMB_TYPE_CACHE' => 7, # processor cache (R) - 'SMB_TYPE_PORT' => 8, # port connector - 'SMB_TYPE_SLOT' => 9, # upgradeable system slot (R) - 'SMB_TYPE_OBDEVS' => 10, # on-board devices - 'SMB_TYPE_OEMSTR' => 11, # OEM string table - 'SMB_TYPE_SYSCONFSTR' => 12, # system configuration string table - 'SMB_TYPE_LANG' => 13, # BIOS language information - 'SMB_TYPE_GROUP' => 14, # group associations - 'SMB_TYPE_EVENTLOG' => 15, # system event log - 'SMB_TYPE_MEMARRAY' => 16, # physical memory array (R) - 'SMB_TYPE_MEMDEVICE' => 17, # memory device (R) - 'SMB_TYPE_MEMERR32' => 18, # 32-bit memory error information - 'SMB_TYPE_MEMARRAYMAP' => 19, # memory array mapped address (R) - 'SMB_TYPE_MEMDEVICEMAP' => 20, # memory device mapped address (R) - 'SMB_TYPE_POINTDEV' => 21, # built-in pointing device - 'SMB_TYPE_BATTERY' => 22, # portable battery - 'SMB_TYPE_RESET' => 23, # system reset settings - 'SMB_TYPE_SECURITY' => 24, # hardware security settings - 'SMB_TYPE_POWERCTL' => 25, # system power controls - 'SMB_TYPE_VPROBE' => 26, # voltage probe - 'SMB_TYPE_COOLDEV' => 27, # cooling device - 'SMB_TYPE_TPROBE' => 28, # temperature probe - 'SMB_TYPE_IPROBE' => 29, # current probe - 'SMB_TYPE_OOBRA' => 30, # out-of-band remote access facility - 'SMB_TYPE_BIS' => 31, # boot integrity services - 'SMB_TYPE_BOOT' => 32, # system boot status (R) - 'SMB_TYPE_MEMERR64' => 33, # 64-bit memory error information - 'SMB_TYPE_MGMTDEV' => 34, # management device - 'SMB_TYPE_MGMTDEVCP' => 35, # management device component - 'SMB_TYPE_MGMTDEVDATA' => 36, # management device threshold data - 'SMB_TYPE_MEMCHAN' => 37, # memory channel - 'SMB_TYPE_IPMIDEV' => 38, # IPMI device information - 'SMB_TYPE_POWERSUP' => 39, # system power supply - 'SMB_TYPE_ADDINFO' => 40, # additional information - 'SMB_TYPE_OBDEVEXT' => 41, # on-board device extended info - 'SMB_TYPE_MCHI' => 42, # mgmt controller host interface - 'SMB_TYPE_INACTIVE' => 126, # inactive table entry - 'SMB_TYPE_EOT' => 127, # end of table - 'SMB_TYPE_OEM_LO' => 128, # start of OEM-specific type range - 'SUN_OEM_EXT_PROCESSOR' => 132, # processor extended info - 'SUN_OEM_PCIEXRC' => 138, # PCIE RootComplex/RootPort info - 'SUN_OEM_EXT_MEMARRAY' => 144, # phys memory array extended info - 'SUN_OEM_EXT_MEMDEVICE' => 145, # memory device extended info - 'SMB_TYPE_OEM_HI' => 256, # end of OEM-specific type range + "SMB_TYPE_BIOS" => 0, # BIOS information (R) + "SMB_TYPE_SYSTEM" => 1, # system information (R) + "SMB_TYPE_BASEBOARD" => 2, # base board + "SMB_TYPE_CHASSIS" => 3, # system enclosure or chassis (R) + "SMB_TYPE_PROCESSOR" => 4, # processor (R) + "SMB_TYPE_MEMCTL" => 5, # memory controller (O) + "SMB_TYPE_MEMMOD" => 6, # memory module (O) + "SMB_TYPE_CACHE" => 7, # processor cache (R) + "SMB_TYPE_PORT" => 8, # port connector + "SMB_TYPE_SLOT" => 9, # upgradeable system slot (R) + "SMB_TYPE_OBDEVS" => 10, # on-board devices + "SMB_TYPE_OEMSTR" => 11, # OEM string table + "SMB_TYPE_SYSCONFSTR" => 12, # system configuration string table + "SMB_TYPE_LANG" => 13, # BIOS language information + "SMB_TYPE_GROUP" => 14, # group associations + "SMB_TYPE_EVENTLOG" => 15, # system event log + "SMB_TYPE_MEMARRAY" => 16, # physical memory array (R) + "SMB_TYPE_MEMDEVICE" => 17, # memory device (R) + "SMB_TYPE_MEMERR32" => 18, # 32-bit memory error information + "SMB_TYPE_MEMARRAYMAP" => 19, # memory array mapped address (R) + "SMB_TYPE_MEMDEVICEMAP" => 20, # memory device mapped address (R) + "SMB_TYPE_POINTDEV" => 21, # built-in pointing device + "SMB_TYPE_BATTERY" => 22, # portable battery + "SMB_TYPE_RESET" => 23, # system reset settings + "SMB_TYPE_SECURITY" => 24, # hardware security settings + "SMB_TYPE_POWERCTL" => 25, # system power controls + "SMB_TYPE_VPROBE" => 26, # voltage probe + "SMB_TYPE_COOLDEV" => 27, # cooling device + "SMB_TYPE_TPROBE" => 28, # temperature probe + "SMB_TYPE_IPROBE" => 29, # current probe + "SMB_TYPE_OOBRA" => 30, # out-of-band remote access facility + "SMB_TYPE_BIS" => 31, # boot integrity services + "SMB_TYPE_BOOT" => 32, # system boot status (R) + "SMB_TYPE_MEMERR64" => 33, # 64-bit memory error information + "SMB_TYPE_MGMTDEV" => 34, # management device + "SMB_TYPE_MGMTDEVCP" => 35, # management device component + "SMB_TYPE_MGMTDEVDATA" => 36, # management device threshold data + "SMB_TYPE_MEMCHAN" => 37, # memory channel + "SMB_TYPE_IPMIDEV" => 38, # IPMI device information + "SMB_TYPE_POWERSUP" => 39, # system power supply + "SMB_TYPE_ADDINFO" => 40, # additional information + "SMB_TYPE_OBDEVEXT" => 41, # on-board device extended info + "SMB_TYPE_MCHI" => 42, # mgmt controller host interface + "SMB_TYPE_INACTIVE" => 126, # inactive table entry + "SMB_TYPE_EOT" => 127, # end of table + "SMB_TYPE_OEM_LO" => 128, # start of OEM-specific type range + "SUN_OEM_EXT_PROCESSOR" => 132, # processor extended info + "SUN_OEM_PCIEXRC" => 138, # PCIE RootComplex/RootPort info + "SUN_OEM_EXT_MEMARRAY" => 144, # phys memory array extended info + "SUN_OEM_EXT_MEMDEVICE" => 145, # memory device extended info + "SMB_TYPE_OEM_HI" => 256, # end of OEM-specific type range } # all output lines should fall within one of these patterns @@ -103,9 +103,9 @@ Ohai.plugin(:DMI) do # ==== EXAMPLE: ==== # ID SIZE TYPE # 0 40 SMB_TYPE_BIOS (BIOS information) - # + # # Vendor: HP - # Version String: 2.16 + # Version String: 2.16 # ... similar lines trimmed # Characteristics: 0x7fc9da80 # SMB_BIOSFL_PCI (PCI is supported) @@ -116,7 +116,7 @@ Ohai.plugin(:DMI) do next if blank_line.match(raw_line) # remove/replace any characters that don't fall inside permissible ASCII range, or whitespace - line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, '.') + line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, ".") if (line != raw_line) Ohai::Log.debug("converted characters from line:\n#{raw_line}") end @@ -164,7 +164,7 @@ Ohai.plugin(:DMI) do Ohai::Log.debug("unexpected data line found before header; discarding:\n#{line}") next end - dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = '' + dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = "" field = data[1] elsif extended_data = extended_data_line.match(line) @@ -177,7 +177,7 @@ Ohai.plugin(:DMI) do next end # overwrite "raw" value with a new Mash - dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == 'Mash' + dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == "Mash" dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = extended_data[2] else diff --git a/lib/ohai/plugins/solaris2/filesystem.rb b/lib/ohai/plugins/solaris2/filesystem.rb index 3c029e7b..263ae037 100644 --- a/lib/ohai/plugins/solaris2/filesystem.rb +++ b/lib/ohai/plugins/solaris2/filesystem.rb @@ -42,10 +42,10 @@ Ohai.plugin(:Filesystem) do # Grab file system type from df (must be done separately) so = shell_out("df -na") so.stdout.lines do |line| - next unless (line =~ /^(.+?)\s*: (\S+)\s*$/) + next unless line =~ /^(.+?)\s*: (\S+)\s*$/ mount = $1 - fs.each { |filesystem,fs_attributes| - next unless (fs_attributes[:mount] == mount) + fs.each { |filesystem, fs_attributes| + next unless fs_attributes[:mount] == mount fs[filesystem][:fs_type] = $2 } end @@ -53,7 +53,7 @@ Ohai.plugin(:Filesystem) do # Grab mount information from /bin/mount so = shell_out("mount") so.stdout.lines do |line| - next unless (line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/) + next unless line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/ filesystem = $2 fs[filesystem] = Mash.new unless fs.has_key?(filesystem) fs[filesystem][:mount] = $1 @@ -69,30 +69,30 @@ Ohai.plugin(:Filesystem) do if configuration(:zfs_properties).nil? || configuration(:zfs_properties).empty? zfs_get << "all" else - zfs_get << [configuration(:zfs_properties)].join(',') + zfs_get << [configuration(:zfs_properties)].join(",") end so = shell_out(zfs_get) so.stdout.lines do |line| - next unless (line =~ /^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)$/) + next unless line =~ /^([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)$/ filesystem = $1 zfs[filesystem] = Mash.new unless zfs.has_key?(filesystem) - zfs[filesystem][:values] = Mash.new unless zfs[filesystem].has_key?('values') - zfs[filesystem][:sources] = Mash.new unless zfs[filesystem].has_key?('sources') + zfs[filesystem][:values] = Mash.new unless zfs[filesystem].has_key?("values") + zfs[filesystem][:sources] = Mash.new unless zfs[filesystem].has_key?("sources") zfs[filesystem][:values][$2] = $3 zfs[filesystem][:sources][$2] = $4.chomp end zfs.each { |filesystem, attributes| fs[filesystem] = Mash.new unless fs.has_key?(filesystem) - fs[filesystem][:fs_type] = 'zfs' - fs[filesystem][:mount] = attributes[:values][:mountpoint] if attributes[:values].has_key?('mountpoint') + fs[filesystem][:fs_type] = "zfs" + fs[filesystem][:mount] = attributes[:values][:mountpoint] if attributes[:values].has_key?("mountpoint") fs[filesystem][:zfs_values] = attributes[:values] fs[filesystem][:zfs_sources] = attributes[:sources] # find all zfs parents - parents = filesystem.split('/') + parents = filesystem.split("/") zfs_parents = [] - (0 .. parents.length - 1).to_a.each { |parent_indexes| - next_parent = parents[0 .. parent_indexes].join('/') + (0..parents.length - 1).to_a.each { |parent_indexes| + next_parent = parents[0..parent_indexes].join("/") zfs_parents.push(next_parent) } zfs_parents.pop diff --git a/lib/ohai/plugins/solaris2/memory.rb b/lib/ohai/plugins/solaris2/memory.rb index c818698a..3b727f67 100644 --- a/lib/ohai/plugins/solaris2/memory.rb +++ b/lib/ohai/plugins/solaris2/memory.rb @@ -20,9 +20,9 @@ Ohai.plugin(:Memory) do collect_data(:solaris2) do memory Mash.new memory[:swap] = Mash.new - meminfo = shell_out("prtconf | grep Memory").stdout + meminfo = shell_out("prtconf | grep Memory").stdout memory[:total] = "#{meminfo.split[2].to_i * 1024}kB" - + tokens = shell_out("swap -s").stdout.strip.split used_swap = tokens[8][0..-1].to_i #strip k from end free_swap = tokens[10][0..-1].to_i #strip k from end diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb index 2c78e60a..8bf56a6f 100644 --- a/lib/ohai/plugins/solaris2/network.rb +++ b/lib/ohai/plugins/solaris2/network.rb @@ -73,14 +73,14 @@ Ohai.plugin(:Network) do def arpname_to_ifname(iface, arpname) iface.keys.each do |ifn| - return ifn if ifn.split(':')[0].eql?(arpname) + return ifn if ifn.split(":")[0].eql?(arpname) end nil end collect_data(:solaris2) do - require 'scanf' + require "scanf" iface = Mash.new network Mash.new unless network @@ -98,7 +98,7 @@ Ohai.plugin(:Network) do iface[cint][:mtu] = $2 iface[cint][:index] = $3 if line =~ / flags\=\d+\<((ADDRCONF|ANYCAST|BROADCAST|CoS|DEPRECATED|DHCP|DUPLICATE|FAILED|FIXEDMTU|INACTIVE|L3PROTECT|LOOPBACK|MIP|MULTI_BCAST|MULTICAST|NOARP|NOFAILOVER|NOLOCAL|NONUD|NORTEXCH|NOXMIT|OFFLINE|POINTOPOINT|PREFERRED|PRIVATE|ROUTER|RUNNING|STANDBY|TEMPORARY|UNNUMBERED|UP|VIRTUAL|XRESOLV|IPv4|IPv6|,)+)\>\s/ - flags = $1.split(',') + flags = $1.split(",") else flags = Array.new end @@ -111,11 +111,11 @@ Ohai.plugin(:Network) do end if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8})\s*$/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*"."} + iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * "." } end if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] - iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*".", "broadcast" => $4 } + iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf("%2x" * 4) * ".", "broadcast" => $4 } end if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)\/(\d+)\s*$/ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses] diff --git a/lib/ohai/plugins/solaris2/virtualization.rb b/lib/ohai/plugins/solaris2/virtualization.rb index 29abbe03..13ee7839 100644 --- a/lib/ohai/plugins/solaris2/virtualization.rb +++ b/lib/ohai/plugins/solaris2/virtualization.rb @@ -22,9 +22,9 @@ Ohai.plugin(:Virtualization) do provides "virtualization" def collect_solaris_guestid - command = '/usr/sbin/zoneadm list -p' + command = "/usr/sbin/zoneadm list -p" so = shell_out(command) - so.stdout.split(':').first + so.stdout.split(":").first end collect_data(:solaris2) do @@ -41,7 +41,7 @@ Ohai.plugin(:Virtualization) do end # http://www.dmo.ca/blog/detecting-virtualization-on-linux - smbios_path= Ohai.abs_path( "/usr/sbin/smbios" ) + smbios_path = Ohai.abs_path( "/usr/sbin/smbios" ) if File.exists?(smbios_path) so = shell_out(smbios_path) case so.stdout @@ -60,32 +60,32 @@ Ohai.plugin(:Virtualization) do end end - if File.executable?('/usr/sbin/zoneadm') + if File.executable?("/usr/sbin/zoneadm") zones = Mash.new so = shell_out("zoneadm list -pc") so.stdout.lines do |line| info = line.chomp.split(/:/) zones[info[1]] = { - 'id' => info[0], - 'state' => info[2], - 'root' => info[3], - 'uuid' => info[4], - 'brand' => info[5], - 'ip' => info[6], + "id" => info[0], + "state" => info[2], + "root" => info[3], + "uuid" => info[4], + "brand" => info[5], + "ip" => info[6], } end - if (zones.length == 1) + if zones.length == 1 first_zone = zones.keys[0] - unless( first_zone == 'global') - virtualization[:system] = 'zone' - virtualization[:role] = 'guest' - virtualization[:guest_uuid] = zones[first_zone]['uuid'] + unless( first_zone == "global") + virtualization[:system] = "zone" + virtualization[:role] = "guest" + virtualization[:guest_uuid] = zones[first_zone]["uuid"] virtualization[:guest_id] = collect_solaris_guestid end - elsif (zones.length > 1) - virtualization[:system] = 'zone' - virtualization[:role] = 'host' + elsif zones.length > 1 + virtualization[:system] = "zone" + virtualization[:role] = "host" virtualization[:guests] = zones end end diff --git a/lib/ohai/plugins/ssh_host_key.rb b/lib/ohai/plugins/ssh_host_key.rb index 93fbff27..0491f855 100644 --- a/lib/ohai/plugins/ssh_host_key.rb +++ b/lib/ohai/plugins/ssh_host_key.rb @@ -28,8 +28,8 @@ Ohai.plugin(:SSHHostKey) do [ "rsa", nil ] when /^ecdsa/ [ "ecdsa", content[0] ] - when 'ssh-ed25519' - [ 'ed25519', nil ] + when "ssh-ed25519" + [ "ed25519", nil ] else [ nil, nil ] end diff --git a/lib/ohai/plugins/uptime.rb b/lib/ohai/plugins/uptime.rb index f4bd5f4e..c1cc5be5 100644 --- a/lib/ohai/plugins/uptime.rb +++ b/lib/ohai/plugins/uptime.rb @@ -24,7 +24,7 @@ # limitations under the License. # -require 'ohai/mixin/seconds_to_human' +require "ohai/mixin/seconds_to_human" Ohai.plugin(:Uptime) do provides "uptime", "uptime_seconds" @@ -43,7 +43,7 @@ Ohai.plugin(:Uptime) do end collect_data(:hpux, :default) do - require 'sigar' + require "sigar" sigar = Sigar.new uptime = sigar.uptime.uptime @@ -94,11 +94,10 @@ Ohai.plugin(:Uptime) do end collect_data(:windows) do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" wmi = WmiLite::Wmi.new - uptime_seconds wmi.first_of('Win32_PerfFormattedData_PerfOS_System')['systemuptime'].to_i + uptime_seconds wmi.first_of("Win32_PerfFormattedData_PerfOS_System")["systemuptime"].to_i uptime seconds_to_human(uptime_seconds) end end - diff --git a/lib/ohai/plugins/virtualbox.rb b/lib/ohai/plugins/virtualbox.rb index 77e25c28..435f649f 100644 --- a/lib/ohai/plugins/virtualbox.rb +++ b/lib/ohai/plugins/virtualbox.rb @@ -17,10 +17,10 @@ # Ohai.plugin(:Virtualbox) do - provides 'virtualbox' + provides "virtualbox" collect_data do - so = shell_out('VBoxControl guestproperty enumerate') + so = shell_out("VBoxControl guestproperty enumerate") if so.exitstatus == 0 virtualbox Mash.new virtualbox[:host] = Mash.new diff --git a/lib/ohai/plugins/virtualization.rb b/lib/ohai/plugins/virtualization.rb index fa126f32..a07f336e 100644 --- a/lib/ohai/plugins/virtualization.rb +++ b/lib/ohai/plugins/virtualization.rb @@ -24,31 +24,31 @@ Ohai.plugin(:VirtualizationInfo) do collect_data do unless virtualization.nil? || !(virtualization[:role].eql?("host")) begin - require 'libvirt' - require 'hpricot' + require "libvirt" + require "hpricot" - emu = (virtualization[:system].eql?('kvm') ? 'qemu' : virtualization[:system]) - virtualization[:libvirt_version] = Libvirt::version(emu)[0].to_s + emu = (virtualization[:system].eql?("kvm") ? "qemu" : virtualization[:system]) + virtualization[:libvirt_version] = Libvirt.version(emu)[0].to_s - virtconn = Libvirt::open_read_only("#{emu}:///system") + virtconn = Libvirt.open_read_only("#{emu}:///system") virtualization[:uri] = virtconn.uri virtualization[:capabilities] = Mash.new - virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect {|line| line.strip}).join + virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect { |line| line.strip }).join #xdoc = Hpricot virtualization[:capabilities][:xml_desc] virtualization[:nodeinfo] = Mash.new ni = virtconn.node_get_info - ['cores','cpus','memory','mhz','model','nodes','sockets','threads'].each {|a| virtualization[:nodeinfo][a] = ni.send(a)} + %w{cores cpus memory mhz model nodes sockets threads}.each { |a| virtualization[:nodeinfo][a] = ni.send(a) } virtualization[:domains] = Mash.new virtconn.list_domains.each do |d| dv = virtconn.lookup_domain_by_id d virtualization[:domains][dv.name] = Mash.new virtualization[:domains][dv.name][:id] = d - virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect {|line| line.strip}).join - ['os_type','uuid'].each {|a| virtualization[:domains][dv.name][a] = dv.send(a)} - ['cpu_time','max_mem','memory','nr_virt_cpu','state'].each {|a| virtualization[:domains][dv.name][a] = dv.info.send(a)} + virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect { |line| line.strip }).join + %w{os_type uuid}.each { |a| virtualization[:domains][dv.name][a] = dv.send(a) } + %w{cpu_time max_mem memory nr_virt_cpu state}.each { |a| virtualization[:domains][dv.name][a] = dv.info.send(a) } #xdoc = Hpricot virtualization[:domains][dv.name][:xml_desc] end @@ -57,8 +57,8 @@ Ohai.plugin(:VirtualizationInfo) do virtconn.list_networks.each do |n| nv = virtconn.lookup_network_by_name n virtualization[:networks][n] = Mash.new - virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect {|line| line.strip}).join - ['bridge_name','uuid'].each {|a| virtualization[:networks][n][a] = nv.send(a)} + virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect { |line| line.strip }).join + %w{bridge_name uuid}.each { |a| virtualization[:networks][n][a] = nv.send(a) } #xdoc = Hpricot virtualization[:networks][n][:xml_desc] end @@ -67,17 +67,17 @@ Ohai.plugin(:VirtualizationInfo) do virtconn.list_storage_pools.each do |pool| sp = virtconn.lookup_storage_pool_by_name pool virtualization[:storage][pool] = Mash.new - virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect {|line| line.strip}).join - ['autostart','uuid'].each {|a| virtualization[:storage][pool][a] = sp.send(a)} - ['allocation','available','capacity','state'].each {|a| virtualization[:storage][pool][a] = sp.info.send(a)} + virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect { |line| line.strip }).join + %w{autostart uuid}.each { |a| virtualization[:storage][pool][a] = sp.send(a) } + %w{allocation available capacity state}.each { |a| virtualization[:storage][pool][a] = sp.info.send(a) } #xdoc = Hpricot virtualization[:storage][pool][:xml_desc] virtualization[:storage][pool][:volumes] = Mash.new sp.list_volumes.each do |v| virtualization[:storage][pool][:volumes][v] = Mash.new sv = sp.lookup_volume_by_name v - ['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)} - ['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)} + %w{key name path}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a) } + %w{allocation capacity type}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a) } end end diff --git a/lib/ohai/plugins/vmware.rb b/lib/ohai/plugins/vmware.rb index 079f39e9..53327e41 100644 --- a/lib/ohai/plugins/vmware.rb +++ b/lib/ohai/plugins/vmware.rb @@ -49,7 +49,7 @@ Ohai.plugin(:VMware) do # vmware-toolbox-cmd stat commands # Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value # to attribute "vmware[:]" - [ "hosttime", "speed", "sessionid", "balloon", "swap", "memlimit", "memres", "cpures", "cpulimit" ].each do |param| + %w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param| vmware[param] = from_cmd("#{vmtools_path} stat #{param}") if vmware[param] =~ /UpdateInfo failed/ vmware[param] = nil @@ -58,7 +58,7 @@ Ohai.plugin(:VMware) do # vmware-toolbox-cmd status commands # Iterate through each parameter supported by the "vwware-toolbox-cmd status" command, assign value # to attribute "vmware[:]" - [ "upgrade", "timesync" ].each do |param| + %w{upgrade timesync}.each do |param| vmware[param] = from_cmd("#{vmtools_path} #{param} status") end rescue diff --git a/lib/ohai/plugins/windows/cpu.rb b/lib/ohai/plugins/windows/cpu.rb index 50591780..7d07c5f0 100644 --- a/lib/ohai/plugins/windows/cpu.rb +++ b/lib/ohai/plugins/windows/cpu.rb @@ -20,14 +20,14 @@ Ohai.plugin(:CPU) do provides "cpu" collect_data(:windows) do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" cpu Mash.new cores = 0 logical_processors = 0 wmi = WmiLite::Wmi.new - processors = wmi.instances_of('Win32_Processor') + processors = wmi.instances_of("Win32_Processor") processors.each_with_index do |processor, index| current_cpu = index.to_s @@ -43,23 +43,23 @@ Ohai.plugin(:CPU) do # begin - cpu[current_cpu]["cores"] = processor['numberofcores'] - cores += processor['numberofcores'] + cpu[current_cpu]["cores"] = processor["numberofcores"] + cores += processor["numberofcores"] rescue NoMethodError => e Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370") cpu[current_cpu]["cores"] = nil end - logical_processors += processor['numberoflogicalprocessors'] - cpu[current_cpu]["vendor_id"] = processor['manufacturer'] - cpu[current_cpu]["family"] = processor['family'].to_s - cpu[current_cpu]["model"] = processor['revision'].to_s - cpu[current_cpu]["stepping"] = processor['stepping'].nil? \ - ? processor['description'].match(/Stepping\s+(\d+)/)[1] \ - : processor['stepping'] - cpu[current_cpu]["physical_id"] = processor['deviceid'] - cpu[current_cpu]["model_name"] = processor['description'] - cpu[current_cpu]["mhz"] = processor['maxclockspeed'].to_s + logical_processors += processor["numberoflogicalprocessors"] + cpu[current_cpu]["vendor_id"] = processor["manufacturer"] + cpu[current_cpu]["family"] = processor["family"].to_s + cpu[current_cpu]["model"] = processor["revision"].to_s + cpu[current_cpu]["stepping"] = processor["stepping"].nil? \ + ? processor["description"].match(/Stepping\s+(\d+)/)[1] \ + : processor["stepping"] + cpu[current_cpu]["physical_id"] = processor["deviceid"] + cpu[current_cpu]["model_name"] = processor["description"] + cpu[current_cpu]["mhz"] = processor["maxclockspeed"].to_s cpu[current_cpu]["cache_size"] = "#{processor['l2cachesize']} KB" end diff --git a/lib/ohai/plugins/windows/drivers.rb b/lib/ohai/plugins/windows/drivers.rb index 91c4c8dc..425d33dc 100644 --- a/lib/ohai/plugins/windows/drivers.rb +++ b/lib/ohai/plugins/windows/drivers.rb @@ -22,23 +22,23 @@ Ohai.plugin(:Drivers) do collect_data(:windows) do if configuration(:enabled) - require 'wmi-lite/wmi' + require "wmi-lite/wmi" kext = Mash.new pnp_drivers = Mash.new wmi = WmiLite::Wmi.new - drivers = wmi.instances_of('Win32_PnPSignedDriver') + drivers = wmi.instances_of("Win32_PnPSignedDriver") drivers.each do |driver| - pnp_drivers[driver['deviceid']] = Mash.new + pnp_drivers[driver["deviceid"]] = Mash.new driver.wmi_ole_object.properties_.each do |p| - pnp_drivers[driver['deviceid']][p.name.wmi_underscore.to_sym] = driver[p.name.downcase] + pnp_drivers[driver["deviceid"]][p.name.wmi_underscore.to_sym] = driver[p.name.downcase] end - if driver['devicename'] - kext[driver['devicename']] = pnp_drivers[driver['deviceid']] - kext[driver['devicename']][:version] = pnp_drivers[driver['deviceid']][:driver_version] - kext[driver['devicename']][:date] = pnp_drivers[driver['deviceid']][:driver_date] ? pnp_drivers[driver['deviceid']][:driver_date].to_s[0..7] : nil + if driver["devicename"] + kext[driver["devicename"]] = pnp_drivers[driver["deviceid"]] + kext[driver["devicename"]][:version] = pnp_drivers[driver["deviceid"]][:driver_version] + kext[driver["devicename"]][:date] = pnp_drivers[driver["deviceid"]][:driver_date] ? pnp_drivers[driver["deviceid"]][:driver_date].to_s[0..7] : nil end end diff --git a/lib/ohai/plugins/windows/filesystem.rb b/lib/ohai/plugins/windows/filesystem.rb index 9d6efa58..7b226526 100644 --- a/lib/ohai/plugins/windows/filesystem.rb +++ b/lib/ohai/plugins/windows/filesystem.rb @@ -21,7 +21,7 @@ Ohai.plugin(:Filesystem) do collect_data(:windows) do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" fs = Mash.new ld_info = Mash.new @@ -30,10 +30,10 @@ Ohai.plugin(:Filesystem) do # Grab filesystem data from WMI # Note: we should really be parsing Win32_Volume and Win32_Mapped drive - disks = wmi.instances_of('Win32_LogicalDisk') + disks = wmi.instances_of("Win32_LogicalDisk") disks.each do |disk| - filesystem = disk['deviceid'] + filesystem = disk["deviceid"] fs[filesystem] = Mash.new ld_info[filesystem] = Mash.new disk.wmi_ole_object.properties_.each do |p| @@ -42,7 +42,7 @@ Ohai.plugin(:Filesystem) do fs[filesystem][:kb_size] = ld_info[filesystem][:size].to_i / 1000 fs[filesystem][:kb_available] = ld_info[filesystem][:free_space].to_i / 1000 fs[filesystem][:kb_used] = fs[filesystem][:kb_size].to_i - fs[filesystem][:kb_available].to_i - fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0) + fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0) fs[filesystem][:mount] = ld_info[filesystem][:name] fs[filesystem][:fs_type] = ld_info[filesystem][:file_system].downcase unless ld_info[filesystem][:file_system] == nil fs[filesystem][:volume_name] = ld_info[filesystem][:volume_name] diff --git a/lib/ohai/plugins/windows/memory.rb b/lib/ohai/plugins/windows/memory.rb index f62d84db..e0bb46f0 100644 --- a/lib/ohai/plugins/windows/memory.rb +++ b/lib/ohai/plugins/windows/memory.rb @@ -35,4 +35,4 @@ Ohai.plugin(:Memory) do # SwapFree memory[:swap][:free] = os["FreeSpaceInPagingFiles"] + "kB" end -end \ No newline at end of file +end diff --git a/lib/ohai/plugins/windows/network.rb b/lib/ohai/plugins/windows/network.rb index d9e250eb..65d76cd1 100644 --- a/lib/ohai/plugins/windows/network.rb +++ b/lib/ohai/plugins/windows/network.rb @@ -27,7 +27,7 @@ Ohai.plugin(:Network) do collect_data(:windows) do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" iface = Mash.new iface_config = Mash.new @@ -40,11 +40,11 @@ Ohai.plugin(:Network) do # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217%28v=vs.85%29.aspx wmi = WmiLite::Wmi.new - adapters = wmi.instances_of('Win32_NetworkAdapterConfiguration') + adapters = wmi.instances_of("Win32_NetworkAdapterConfiguration") adapters.each do |adapter| - i = adapter['index'] + i = adapter["index"] iface_config[i] = Mash.new adapter.wmi_ole_object.properties_.each do |p| iface_config[i][p.name.wmi_underscore.to_sym] = adapter[p.name.downcase] @@ -53,10 +53,10 @@ Ohai.plugin(:Network) do # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx - adapters = wmi.instances_of('Win32_NetworkAdapter') + adapters = wmi.instances_of("Win32_NetworkAdapter") adapters.each do |adapter| - i = adapter['index'] + i = adapter["index"] iface_instance[i] = Mash.new adapter.wmi_ole_object.properties_.each do |p| iface_instance[i][p.name.wmi_underscore.to_sym] = adapter[p.name.downcase] @@ -76,7 +76,7 @@ Ohai.plugin(:Network) do ip = iface[cint][:configuration][:ip_address][i] _ip = IPAddress("#{ip}/#{iface[cint][:configuration][:ip_subnet][i]}") iface[cint][:addresses][ip] = Mash.new( - :prefixlen => _ip.prefix + :prefixlen => _ip.prefix, ) if _ip.ipv6? # inet6 address @@ -84,7 +84,7 @@ Ohai.plugin(:Network) do iface[cint][:addresses][ip][:scope] = "Link" if ip =~ /^fe80/i else # should be an inet4 address - iface[cint][:addresses][ip][:netmask] = _ip.netmask.to_s + iface[cint][:addresses][ip][:netmask] = _ip.netmask.to_s if iface[cint][:configuration][:ip_use_zero_broadcast] iface[cint][:addresses][ip][:broadcast] = _ip.network.to_s else @@ -110,7 +110,7 @@ Ohai.plugin(:Network) do end end - cint=nil + cint = nil so = shell_out("arp -a") if so.exitstatus == 0 so.stdout.lines do |line| @@ -119,7 +119,7 @@ Ohai.plugin(:Network) do end next unless iface[cint] if line =~ /^\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-fA-F0-9\:-]+)/ - iface[cint][:arp][$1] = $2.gsub("-",":").downcase + iface[cint][:arp][$1] = $2.gsub("-", ":").downcase end end end diff --git a/lib/ohai/plugins/windows/platform.rb b/lib/ohai/plugins/windows/platform.rb index ba772408..ecdcb777 100644 --- a/lib/ohai/plugins/windows/platform.rb +++ b/lib/ohai/plugins/windows/platform.rb @@ -27,8 +27,7 @@ Ohai.plugin(:Platform) do collect_data(:windows) do platform os - platform_version kernel['release'] + platform_version kernel["release"] platform_family "windows" end end - diff --git a/lib/ohai/plugins/windows/virtualization.rb b/lib/ohai/plugins/windows/virtualization.rb index a8b0d211..947e1697 100644 --- a/lib/ohai/plugins/windows/virtualization.rb +++ b/lib/ohai/plugins/windows/virtualization.rb @@ -19,38 +19,38 @@ # Ohai.plugin(:Virtualization) do - provides 'virtualization' + provides "virtualization" collect_data(:windows) do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" virtualization Mash.new unless virtualization virtualization[:systems] = Mash.new unless virtualization[:systems] # Grab BIOS data from WMI to determine vendor information wmi = WmiLite::Wmi.new - bios = wmi.instances_of('Win32_BIOS') + bios = wmi.instances_of("Win32_BIOS") - case bios[0]['manufacturer'] - when 'innotek GmbH' - virtualization[:system] = 'vbox' - virtualization[:role] = 'guest' - virtualization[:systems][:vbox] = 'guest' - when 'Parallels Software International Inc.' - virtualization[:system] = 'parallels' - virtualization[:role] = 'guest' - virtualization[:systems][:parallels] = 'guest' - when 'Bochs' + case bios[0]["manufacturer"] + when "innotek GmbH" + virtualization[:system] = "vbox" + virtualization[:role] = "guest" + virtualization[:systems][:vbox] = "guest" + when "Parallels Software International Inc." + virtualization[:system] = "parallels" + virtualization[:role] = "guest" + virtualization[:systems][:parallels] = "guest" + when "Bochs" virtualization[:system] = "kvm" virtualization[:role] = "guest" virtualization[:systems][:kvm] = "guest" end # vmware fusion detection - if bios[0]['serialnumber'] =~ /VMware/ - virtualization[:system] = 'vmware' - virtualization[:role] = 'guest' - virtualization[:systems][:vmware] = 'guest' + if bios[0]["serialnumber"] =~ /VMware/ + virtualization[:system] = "vmware" + virtualization[:role] = "guest" + virtualization[:systems][:vmware] = "guest" end end end diff --git a/lib/ohai/provides_map.rb b/lib/ohai/provides_map.rb index 4001844e..da7d8be1 100644 --- a/lib/ohai/provides_map.rb +++ b/lib/ohai/provides_map.rb @@ -17,10 +17,10 @@ # limitations under the License. # -require 'ohai/mash' -require 'ohai/exception' -require 'ohai/mixin/os' -require 'ohai/dsl' +require "ohai/mash" +require "ohai/exception" +require "ohai/mixin/os" +require "ohai/dsl" module Ohai class ProvidesMap @@ -102,7 +102,7 @@ module Ohai plugins.uniq end - def all_plugins(attribute_filter=nil) + def all_plugins(attribute_filter = nil) if attribute_filter.nil? collected = [] collect_plugins_in(map, collected).uniq @@ -117,7 +117,7 @@ module Ohai raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: #{attribute}" if attribute.match(/\/\/+/) raise Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': #{attribute}" if attribute.match(/\/$/) - parts = attribute.split('/') + parts = attribute.split("/") parts.shift if parts.length != 0 && parts[0].length == 0 # attribute begins with a '/' parts end @@ -144,7 +144,7 @@ module Ohai # attribute under attr (if attribute = attr/sub1/sub2 then we # search provides_map[attr] for sub1/sub2) unless rest.empty? - subtree = select_closest_subtree(provides_map[attr], rest.join('/')) + subtree = select_closest_subtree(provides_map[attr], rest.join("/")) end if subtree.nil? diff --git a/lib/ohai/runner.rb b/lib/ohai/runner.rb index 03bf4968..967c96ea 100644 --- a/lib/ohai/runner.rb +++ b/lib/ohai/runner.rb @@ -17,7 +17,7 @@ # limitations under the License # -require 'ohai/dsl' +require "ohai/dsl" module Ohai class Runner @@ -50,7 +50,7 @@ module Ohai raise rescue SystemExit # abort or exit from plug-in should exit Ohai with failure code raise - rescue Exception,Errno::ENOENT => e + rescue Exception, Errno::ENOENT => e Ohai::Log.debug("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}") end end @@ -63,7 +63,7 @@ module Ohai def run_v7_plugin(plugin) visited = [ plugin ] - while !visited.empty? + until visited.empty? next_plugin = visited.pop next if next_plugin.has_run? diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb index d44c9d7c..c36ac7f6 100644 --- a/lib/ohai/system.rb +++ b/lib/ohai/system.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'ohai/loader' -require 'ohai/log' -require 'ohai/mash' -require 'ohai/runner' -require 'ohai/dsl' -require 'ohai/mixin/command' -require 'ohai/mixin/os' -require 'ohai/mixin/string' -require 'ohai/mixin/constant_helper' -require 'ohai/provides_map' -require 'ohai/hints' -require 'mixlib/shellout' +require "ohai/loader" +require "ohai/log" +require "ohai/mash" +require "ohai/runner" +require "ohai/dsl" +require "ohai/mixin/command" +require "ohai/mixin/os" +require "ohai/mixin/string" +require "ohai/mixin/constant_helper" +require "ohai/provides_map" +require "ohai/hints" +require "mixlib/shellout" module Ohai class System @@ -65,7 +65,7 @@ module Ohai @data[key] end - def all_plugins(attribute_filter=nil) + def all_plugins(attribute_filter = nil) # Reset the system when all_plugins is called since this function # can be run multiple times in order to pick up any changes in the # config or plugins with Chef. @@ -88,7 +88,7 @@ module Ohai # Users who are migrating from ohai 6 may give one or more Ohai 6 plugin # names as the +attribute_filter+. In this case we return early because # the v7 plugin provides map will not have an entry for this plugin. - if attribute_filter and Array(attribute_filter).all? {|filter_item| have_v6_plugin?(filter_item) } + if attribute_filter and Array(attribute_filter).all? { |filter_item| have_v6_plugin?(filter_item) } return true end @@ -104,7 +104,7 @@ module Ohai end def have_v6_plugin?(name) - @v6_dependency_solver.values.any? {|v6plugin| v6plugin.name == name } + @v6_dependency_solver.values.any? { |v6plugin| v6plugin.name == name } end def pathify_v6_plugin(plugin_name) @@ -117,7 +117,7 @@ module Ohai # Make sure that you are not breaking backwards compatibility # if you are changing any of the APIs below. # - def require_plugin(plugin_ref, force=false) + def require_plugin(plugin_ref, force = false) plugins = [ ] # This method is only callable by version 6 plugins. # First we check if there exists a v6 plugin that fulfills the dependency. @@ -147,7 +147,7 @@ module Ohai rescue Ohai::Exceptions::DependencyCycle, Ohai::Exceptions::AttributeNotFound => e Ohai::Log.error("Encountered error while running plugins: #{e.inspect}") raise - rescue Exception,Errno::ENOENT => e + rescue Exception, Errno::ENOENT => e Ohai::Log.debug("Plugin #{plugin.name} threw exception #{e.inspect} #{e.backtrace.join("\n")}") end end @@ -163,7 +163,7 @@ module Ohai # # This method takes a naive approach to v6 plugins: it simply re-runs all # of them whenever called. - def refresh_plugins(attribute_filter=nil) + def refresh_plugins(attribute_filter = nil) Ohai::Hints.refresh_hints() @provides_map.all_plugins(attribute_filter).each do |plugin| plugin.reset! @@ -181,7 +181,7 @@ module Ohai # # Pretty Print this object as JSON # - def json_pretty_print(item=nil) + def json_pretty_print(item = nil) FFI_Yajl::Encoder.new(pretty: true, validate_utf8: false).encode(item || @data) end @@ -192,7 +192,7 @@ module Ohai end raise ArgumentError, "I cannot find an attribute named #{a}!" if data.nil? case data - when Hash,Mash,Array,Fixnum + when Hash, Mash, Array, Fixnum json_pretty_print(data) when String if data.respond_to?(:lines) @@ -206,12 +206,13 @@ module Ohai end private + def configure_ohai Ohai::Config.merge_deprecated_config Ohai.config.merge!(@config) if Ohai.config[:directory] && - !Ohai.config[:plugin_path].include?(Ohai.config[:directory]) + !Ohai.config[:plugin_path].include?(Ohai.config[:directory]) Ohai.config[:plugin_path] << Ohai.config[:directory] end end diff --git a/lib/ohai/util/file_helper.rb b/lib/ohai/util/file_helper.rb index 2b1a83ef..1f78d5a6 100644 --- a/lib/ohai/util/file_helper.rb +++ b/lib/ohai/util/file_helper.rb @@ -22,7 +22,7 @@ module Ohai module Util module FileHelper def which(cmd) - paths = ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ] + paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] paths.each do |path| filename = File.join(path, cmd) return filename if File.executable?(filename) @@ -32,4 +32,3 @@ module Ohai end end end - diff --git a/lib/ohai/util/ip_helper.rb b/lib/ohai/util/ip_helper.rb index 5b848e94..f22c4fdd 100644 --- a/lib/ohai/util/ip_helper.rb +++ b/lib/ohai/util/ip_helper.rb @@ -14,14 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ipaddress' +require "ipaddress" module Ohai module Util module IpHelper # Corresponding to RFC 4192 + RFC 4193 - IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress('fe80::/10') - IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress('fc00::/7') + IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress("fe80::/10") + IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress("fc00::/7") def private_address?(addr) ip = IPAddress(addr) @@ -47,7 +47,7 @@ module Ohai if ip.respond_to? :loopback? ip.loopback? else - IPAddress('127.0.0.0/8').include? ip + IPAddress("127.0.0.0/8").include? ip end end end diff --git a/lib/ohai/util/win32.rb b/lib/ohai/util/win32.rb index 0fac63ac..5cf638d0 100644 --- a/lib/ohai/util/win32.rb +++ b/lib/ohai/util/win32.rb @@ -21,19 +21,19 @@ module Ohai module Win32 if RUBY_PLATFORM =~ /mswin|mingw|windows/ - require 'ffi' + require "ffi" extend FFI::Library - ffi_lib 'advapi32' + ffi_lib "advapi32" attach_function :lookup_account_sid, - :LookupAccountSidA,[ :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :long + :LookupAccountSidA, [ :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer ], :long attach_function :convert_string_sid_to_sid, - :ConvertStringSidToSidA,[ :pointer, :pointer ], :long + :ConvertStringSidToSidA, [ :pointer, :pointer ], :long - ffi_lib 'kernel32' + ffi_lib "kernel32" attach_function :local_free, :LocalFree, [ :pointer ], :long diff --git a/lib/ohai/util/win32/group_helper.rb b/lib/ohai/util/win32/group_helper.rb index 6c4ed1dc..68134d4f 100644 --- a/lib/ohai/util/win32/group_helper.rb +++ b/lib/ohai/util/win32/group_helper.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ohai/util/win32' +require "ohai/util/win32" module Ohai module Util @@ -26,7 +26,7 @@ module Ohai # internal name for the Administrators group, which lets us work # properly in environments with a renamed or localized name for the # Administrators group - BUILTIN_ADMINISTRATORS_SID = 'S-1-5-32-544' + BUILTIN_ADMINISTRATORS_SID = "S-1-5-32-544" def self.windows_root_group_name administrators_group_name_result = nil @@ -40,8 +40,8 @@ module Ohai end administrators_group_name_buffer = 0.chr * 260 - administrators_group_name_length = [administrators_group_name_buffer.length].pack('L') - domain_name_length_buffer = [260].pack('L') + administrators_group_name_length = [administrators_group_name_buffer.length].pack("L") + domain_name_length_buffer = [260].pack("L") sid_use_result = 0.chr * 4 # Use LookupAccountSid rather than WMI's Win32_Group class because WMI will attempt @@ -73,4 +73,3 @@ module Ohai end end end - diff --git a/lib/ohai/version.rb b/lib/ohai/version.rb index ee92b648..4fc09570 100644 --- a/lib/ohai/version.rb +++ b/lib/ohai/version.rb @@ -18,5 +18,5 @@ module Ohai OHAI_ROOT = File.expand_path(File.dirname(__FILE__)) - VERSION = '8.10.0' + VERSION = "8.10.0" end diff --git a/ohai.gemspec b/ohai.gemspec index d7e8ada4..28824396 100644 --- a/ohai.gemspec +++ b/ohai.gemspec @@ -1,6 +1,6 @@ -$:.unshift File.expand_path('../lib', __FILE__) -require 'ohai/version' +$:.unshift File.expand_path("../lib", __FILE__) +require "ohai/version" Gem::Specification.new do |s| s.name = "ohai" @@ -42,8 +42,8 @@ Gem::Specification.new do |s| s.add_development_dependency "rspec_junit_formatter" s.bindir = "bin" - s.executables = %w(ohai) + s.executables = %w{ohai} - s.require_path = 'lib' - s.files = %w(LICENSE README.md Gemfile Rakefile) + Dir.glob("*.gemspec") + Dir.glob("{docs,lib,spec}/**/*") + s.require_path = "lib" + s.files = %w{LICENSE README.md Gemfile Rakefile} + Dir.glob("*.gemspec") + Dir.glob("{docs,lib,spec}/**/*") end diff --git a/platform_simulation_specs/common/ohai_plugin_common.rb b/platform_simulation_specs/common/ohai_plugin_common.rb index ee61609f..78dbc90f 100644 --- a/platform_simulation_specs/common/ohai_plugin_common.rb +++ b/platform_simulation_specs/common/ohai_plugin_common.rb @@ -16,16 +16,15 @@ # limitations under the License. # -require 'rubygems' -require 'ffi_yajl' -require 'ohai' -require 'yaml' +require "rubygems" +require "ffi_yajl" +require "ohai" +require "yaml" module OhaiPluginCommon FAKE_SEP = "___" def fake_command(data, platform, arch, env) - # If the platform or architecture aren't set, take the first one # platform = ENV['OHAI_TEST_PLATFORM'] # arch = ENV['OHAI_TEST_ARCH'] @@ -33,33 +32,32 @@ module OhaiPluginCommon # env = JSON.load(env) - argv = ARGV.map { |arg| if /\ / =~ arg then "\"" + arg + "\"" else arg end }.join ' ' - match = data[platform][arch].select{ |v| v[:params] == argv && v[:env] == env } + argv = ARGV.map { |arg| if /\ / =~ arg then "\"" + arg + "\"" else arg end }.join " " + match = data[platform][arch].select { |v| v[:params] == argv && v[:env] == env } raise "No canned output for these settings." if match.empty? raise "More than one set of data matches these parameters." if match.size > 1 match = match[0] - $stdout.puts match[:stdout] if match[:stdout] != '' - $stderr.puts match[:stderr] if match[:stderr] != '' + $stdout.puts match[:stdout] if match[:stdout] != "" + $stderr.puts match[:stderr] if match[:stderr] != "" exit match[:exit_status] end def data_path - File.expand_path(File.dirname(__FILE__) + '../../../data/plugins') + File.expand_path(File.dirname(__FILE__) + "../../../data/plugins") end - def get_path(path = '') + def get_path(path = "") File.expand_path(File.dirname(__FILE__) + path) end def plugin_path - get_path '/../../../lib/ohai/plugins' + get_path "/../../../lib/ohai/plugins" end # read in the data file for fake executables def read_output( cmd, path = "#{data_path}" ) - #using an anonymous class to minimize scoping issues. @data = Class.new do @instances @@ -74,7 +72,7 @@ module OhaiPluginCommon @instances << current end @methods = [:platform, :arch, :env, :params, :stdout, :stderr, :exit_status] - @methods.each { |m| self.send(:define_method, m.to_s) { |text| push m.to_sym, text }} + @methods.each { |m| self.send(:define_method, m.to_s) { |text| push m.to_sym, text } } #Format data into a form the rest of the app expects def process @@ -85,7 +83,7 @@ module OhaiPluginCommon @instances.each do |i| data[i[:platform]] ||= {} data[i[:platform]][i[:arch]] ||= [] - data[i[:platform]][i[:arch]] << i.reject { |k,v| k == :platform || k == :arch } + data[i[:platform]][i[:arch]] << i.reject { |k, v| k == :platform || k == :arch } end data end @@ -112,8 +110,8 @@ eos # prep fake executable data for writing to a file def data_to_string(data) - a = data.map do |platform,v| - v.map do |arch,v| + a = data.map do |platform, v| + v.map do |arch, v| v.map do |e| to_fake_exe_format platform, arch, e[:env], e[:params], e[:stdout], e[:stderr], e[:exit_status] end @@ -123,23 +121,22 @@ eos end def create_exe(cmd, path, platform, arch, env) - # Create a list of directories needed to be created before the file is created. # Assume that the #{path} directory exists, but that any directories included in #{cmd} may or may not. - dir_list = cmd.split(/\//).inject( [] ) do | acc, ele | + dir_list = cmd.split(/\//).inject( [] ) do |acc, ele| if acc == [] acc << ele else acc << File.join( acc.last, ele ) end - end.reject { | e | e == "" } - dir_list = dir_list.map { |e| File.join( path, e )} + end.reject { |e| e == "" } + dir_list = dir_list.map { |e| File.join( path, e ) } cmd_path = dir_list.pop bat_path = cmd_path + ".bat" # Ensure the directories in #{cmd} get created - this is for absolute path support # This is a workaround: Dir.exists? doesn't exist in 1.8.7 - dir_list.each do | e | + dir_list.each do |e| exists = false begin Dir.new e @@ -174,8 +171,8 @@ eof # the specified regex def clean_path( path, regex ) Dir.glob( File.join( path, "*" )). - reject { | e | e =~ regex }. - each { | e | Mixlib::ShellOut.new( "rm -rf #{ e }" ).run_command } + reject { |e| e =~ regex }. + each { |e| Mixlib::ShellOut.new( "rm -rf #{ e }" ).run_command } end module_function( :fake_command, :data_path, :get_path, :read_output, :clean_path, @@ -186,7 +183,7 @@ end # nil values in test match against both nil and non-existance in source. def subsumes?(source, test, path = [], &block) if source.is_a?( Hash ) && test.is_a?( Hash ) - test.all? { |k,v| subsumes?( source[k], v, path.clone << k, &block )} + test.all? { |k, v| subsumes?( source[k], v, path.clone << k, &block ) } else block.call( path, source, test ) if block source == test @@ -204,7 +201,7 @@ def test_plugin(plugin_names, cmd_list) # clean the path directory, in case a previous test was interrupted OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ - l = lambda do | *args | + l = lambda do |*args| platforms = args[0] archs = args[1] envs = args[2] @@ -221,10 +218,10 @@ def test_plugin(plugin_names, cmd_list) begin # preserve the path - old_path = ENV[ 'PATH' ] + old_path = ENV[ "PATH" ] # create fake executables - cmd_list.each do | c | + cmd_list.each do |c| data = OhaiPluginCommon.read_output( c.gsub( /\//, OhaiPluginCommon::FAKE_SEP )) data = data[platform][arch].select { |f| f[:env] == env } @@ -236,7 +233,7 @@ def test_plugin(plugin_names, cmd_list) end # capture all executions in path dir - ENV['PATH'] = path + ENV["PATH"] = path Ohai.instance_eval do def self.abs_path( abs_path ) File.join( OhaiPluginCommon.get_path, abs_path ) @@ -244,7 +241,7 @@ def test_plugin(plugin_names, cmd_list) end @ohai = Ohai::System.new - plugin_names.each do | plugin_name | + plugin_names.each do |plugin_name| @plugin = get_plugin(plugin_name, @ohai, OhaiPluginCommon.plugin_path) raise "Can not find plugin #{plugin_name}" if @plugin.nil? @plugin.safe_run @@ -255,12 +252,12 @@ def test_plugin(plugin_names, cmd_list) abs_path end end - ENV['PATH'] = old_path + ENV["PATH"] = old_path OhaiPluginCommon.clean_path OhaiPluginCommon.get_path, /^.*\.rb$/ end enc = FFI_Yajl::Encoder - subsumes?( @ohai.data, ohai ) do | path, source, test | + subsumes?( @ohai.data, ohai ) do |path, source, test| path_txt = path.map { |p| "[#{enc.encode( p )}]" }.join if test.nil? txt = "should not set #{path_txt}" diff --git a/platform_simulation_specs/common/ohai_plugin_common_spec.rb b/platform_simulation_specs/common/ohai_plugin_common_spec.rb index 56ed74e6..fd83d986 100644 --- a/platform_simulation_specs/common/ohai_plugin_common_spec.rb +++ b/platform_simulation_specs/common/ohai_plugin_common_spec.rb @@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + "/ohai_plugin_common.rb") describe OhaiPluginCommon, "subsumes?" do before(:each) do - @hash = { "languages" => { "python" => { "version" => "1.6.2", "type" => "interpreted" }}} + @hash = { "languages" => { "python" => { "version" => "1.6.2", "type" => "interpreted" } } } end it "returns true if given an exact duplicate" do @@ -28,25 +28,25 @@ describe OhaiPluginCommon, "subsumes?" do end it "returns false if given an exact duplicate with extra info" do - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => "darwin", "type" => "interpreted" }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => {}, "type" => "interpreted" }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => { "name" => "darwin" }, "type" => "interpreted" }}} ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => "darwin", "type" => "interpreted" } } } ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => {}, "type" => "interpreted" } } } ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2", "os" => { "name" => "darwin" }, "type" => "interpreted" } } } ).should be_false end it "returns true if all elements in the second hash are in the first hash" do - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }}} ).should be_true - subsumes?( @hash, { "languages" => { "python" => {}}} ).should be_true - subsumes?( @hash, { "languages" => {}} ).should be_true + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" } } } ).should be_true + subsumes?( @hash, { "languages" => { "python" => {} } } ).should be_true + subsumes?( @hash, { "languages" => {} } ).should be_true end it "returns true if the second hash contains a key pointing to a nil where the first hash has nothing" do - subsumes?( @hash, { "languages" => { "lua" => nil }} ).should be_true - subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }, "lua" => nil }} ).should be_true + subsumes?( @hash, { "languages" => { "lua" => nil } } ).should be_true + subsumes?( @hash, { "languages" => { "python" => { "version" => "1.6.2" }, "lua" => nil } } ).should be_true end it "returns false if the second hash has nil in the place of a real value" do - subsumes?( @hash, { "languages" => { "python" => { "version" => nil }}} ).should be_false - subsumes?( @hash, { "languages" => { "python" => nil }} ).should be_false - subsumes?( { "languages" => {}}, { "languages" => nil } ).should be_false + subsumes?( @hash, { "languages" => { "python" => { "version" => nil } } } ).should be_false + subsumes?( @hash, { "languages" => { "python" => nil } } ).should be_false + subsumes?( { "languages" => {} }, { "languages" => nil } ).should be_false end end diff --git a/platform_simulation_specs/plugins/c_spec.rb b/platform_simulation_specs/plugins/c_spec.rb index fea35c51..3cd58e81 100644 --- a/platform_simulation_specs/plugins/c_spec.rb +++ b/platform_simulation_specs/plugins/c_spec.rb @@ -16,41 +16,41 @@ # limitations under the License. # -require 'rbconfig' +require "rbconfig" -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin c" do - test_plugin([ "languages", "c" ], [ "/lib/libc.so.6", "/lib64/libc.so.6", "gcc", "cl", "devenv.com", "xlc", "cc", "what" ]) do | p | + test_plugin(%w{languages c}, [ "/lib/libc.so.6", "/lib64/libc.so.6", "gcc", "cl", "devenv.com", "xlc", "cc", "what" ]) do |p| p.test([ "centos-5.5" ], [ "x64" ], [[]], { "languages" => { "c" => { "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)" }, "glibc" => { "version" => "2.5" , "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => { + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "centos-6.2" ], %w{x86 x64}, [[]], { "languages" => { "c" => { "gcc" => { "version" => "4.4.6", "description" => "gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) " }, "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[]], + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [[]], { "languages" => { "c" => { "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, - "gcc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") - p.test([ "ubuntu-12.10" ], [ "x64" ], [[]], { "languages" => { "c" => nil }}, "OC-9993") + "gcc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "ubuntu-12.04", "ubuntu-13.04" ], %w{x86 x64}, [[]], { "languages" => { "c" => nil } }, "OC-9993") + p.test([ "ubuntu-12.10" ], [ "x64" ], [[]], { "languages" => { "c" => nil } }, "OC-9993") p.test([ "centos-5.5" ], [ "x64" ], [[ "gcc" ]], { "languages" => { "c" => { "gcc" => { "version" => "4.1.2", "description" => "gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)" }, "glibc" => { "version" => "2.5", "description" => "GNU C Library stable release version 2.5, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "centos-6.2" ], %w{x86 x64}, [[ "gcc" ]], { "languages" => { "c" => { "gcc" => { "version" => "4.4.7", "description" => "gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) " }, "glibc" => { "version" => "2.12", "description" => "GNU C Library stable release version 2.12, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [[ "gcc" ]], { "languages" => { "c" => { "gcc" => { "version" => "4.4.3", "description" => "gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) " }, "glibc" => { "version" => "2.11.1", "description" => "GNU C Library (Ubuntu EGLIBC 2.11.1-0ubuntu7.12) stable release version 2.11.1, by Roland McGrath et al." }, - "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "gcc" ]], { "languages" => { "c" => { + "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }) + p.test([ "ubuntu-12.04" ], %w{x86 x64}, [[ "gcc" ]], { "languages" => { "c" => { "gcc" => { "version" => "4.6.3", "description" => "gcc verison 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) " }, - "glibc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil }}}, "OC-9993" ) + "glibc" => nil, "cl" => nil, "vs" => nil, "xlc" => nil, "sunpro" => nil, "hpcc" => nil } } }, "OC-9993" ) end end diff --git a/platform_simulation_specs/plugins/erlang_spec.rb b/platform_simulation_specs/plugins/erlang_spec.rb index 2c33bae8..2fc22ec5 100644 --- a/platform_simulation_specs/plugins/erlang_spec.rb +++ b/platform_simulation_specs/plugins/erlang_spec.rb @@ -17,22 +17,22 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin erlang" do - test_plugin([ "languages", "erlang" ], [ "erl" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "erlang" => nil }}) + test_plugin(%w{languages erlang}, [ "erl" ]) do |p| + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "erlang" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "erlang" => nil }}) - p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.7.4", "options" => [ "ASYNC_THREADS", "HIPE" ], "emulator" => "BEAM" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) + { "languages" => { "erlang" => nil } }) + p.test([ "centos-5.9", "centos-6.4" ], %w{x86 x64}, [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.7.4", "options" => %w{ASYNC_THREADS HIPE}, "emulator" => "BEAM" } } }) + p.test([ "ubuntu-12.04" ], %w{x86 x64}, [[ "erlang" ]], + { "languages" => { "erlang" => { "version" => "5.8.5", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "erlang" ]], - { "languages" => { "erlang" => { "version" => "5.9.1", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" }}}) + { "languages" => { "erlang" => { "version" => "5.9.1", "options" => [ "ASYNC_THREADS" ], "emulator" => "BEAM" } } }) end end diff --git a/platform_simulation_specs/plugins/go_spec.rb b/platform_simulation_specs/plugins/go_spec.rb index 239d0c4e..f76f8372 100644 --- a/platform_simulation_specs/plugins/go_spec.rb +++ b/platform_simulation_specs/plugins/go_spec.rb @@ -13,18 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin go" do - test_plugin([ "languages", "go" ], [ "go" ]) do | p | - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "go" => nil }}) + test_plugin(%w{languages go}, [ "go" ]) do |p| + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "go" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "go" => nil }}) - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "go" ]], - { "languages" => { "go" => { "version" => "0.10.2" }}}) + { "languages" => { "go" => nil } }) + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[ "go" ]], + { "languages" => { "go" => { "version" => "0.10.2" } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "go" ]], - { "languages" => { "go" => { "version" => "0.10.2" }}}) + { "languages" => { "go" => { "version" => "0.10.2" } } }) end end diff --git a/platform_simulation_specs/plugins/groovy_spec.rb b/platform_simulation_specs/plugins/groovy_spec.rb index 72697d04..cebbdda4 100644 --- a/platform_simulation_specs/plugins/groovy_spec.rb +++ b/platform_simulation_specs/plugins/groovy_spec.rb @@ -16,25 +16,24 @@ # limitations under the License. # - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin groovy" do - test_plugin([ "languages", "groovy" ], [ "groovy" ]) do | p | + test_plugin(%w{languages groovy}, [ "groovy" ]) do |p| p.test([ "centos-5.5", "ubuntu-12.10" ], [ "x64" ], [[]], - { "languages" => { "groovy" => nil }}) - p.test([ "centos-6.2", "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "groovy" => nil }}) - p.test([ "centos-5.5" ], [ "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "2.1.7" }}}) - p.test([ "centos-6.2" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "2.1.7" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.6.4" }}}) - p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x86", "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.8.6" }}}) - p.test([ "ubuntu-12.10" ], [ "x64" ], [[ "java", "groovy" ]], - { "languages" => { "groovy" => { "version" => "1.8.6" }}}) + { "languages" => { "groovy" => nil } }) + p.test([ "centos-6.2", "ubuntu-12.04", "ubuntu-13.04" ], %w{x86 x64}, [[]], + { "languages" => { "groovy" => nil } }) + p.test([ "centos-5.5" ], [ "x64" ], [%w{java groovy}], + { "languages" => { "groovy" => { "version" => "2.1.7" } } }) + p.test([ "centos-6.2" ], %w{x86 x64}, [%w{java groovy}], + { "languages" => { "groovy" => { "version" => "2.1.7" } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [%w{java groovy}], + { "languages" => { "groovy" => { "version" => "1.6.4" } } }) + p.test([ "ubuntu-12.04", "ubuntu-13.04" ], %w{x86 x64}, [%w{java groovy}], + { "languages" => { "groovy" => { "version" => "1.8.6" } } }) + p.test([ "ubuntu-12.10" ], [ "x64" ], [%w{java groovy}], + { "languages" => { "groovy" => { "version" => "1.8.6" } } }) end end diff --git a/platform_simulation_specs/plugins/java_spec.rb b/platform_simulation_specs/plugins/java_spec.rb index 00049d9b..71e1df11 100644 --- a/platform_simulation_specs/plugins/java_spec.rb +++ b/platform_simulation_specs/plugins/java_spec.rb @@ -17,50 +17,50 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin java (Java5 Client VM)" do - test_plugin([ "languages", "java" ], [ "java" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "java" => nil }}) + test_plugin(%w{languages java}, [ "java" ]) do |p| + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "java" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "java" => nil }}) + { "languages" => { "java" => nil } }) p.test([ "centos-5.9" ], [ "x86" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-i386" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-i386" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "centos-5.9" ], [ "x64" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-x86_64" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.41.1.11.11.90.el5_9-x86_64" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "centos-6.4" ], [ "x86" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-i386" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-i386" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "centos-6.4" ], [ "x64" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_24", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-x86_64" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.11.11.90)", "build" => "rhel-1.62.1.11.11.90.el6_4-x86_64" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "ubuntu-10.04" ], [ "x86" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" } } } }) p.test([ "ubuntu-10.04" ], [ "x64" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.10.04.1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "ubuntu-12.04" ], [ "x86" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, - "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, + "hotspot" => { "name" => "OpenJDK Client VM", "build" => "20.0-b12, mixed mode, sharing" } } } }) p.test([ "ubuntu-12.04" ], [ "x64" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-0ubuntu0.12.04.1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" } } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [["java"]], { "languages" => { "java" => { "version" => "1.6.0_27", - "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-1ubuntu1" }, - "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" }}}}) + "runtime" => { "name" => "OpenJDK Runtime Environment (IcedTea6 1.12.5)", "build" => "6b27-1.12.5-1ubuntu1" }, + "hotspot" => { "name" => "OpenJDK 64-Bit Server VM", "build" => "20.0-b12, mixed mode" } } } }) end end diff --git a/platform_simulation_specs/plugins/kernel_spec.rb b/platform_simulation_specs/plugins/kernel_spec.rb index d397673b..85a6e4bd 100644 --- a/platform_simulation_specs/plugins/kernel_spec.rb +++ b/platform_simulation_specs/plugins/kernel_spec.rb @@ -17,14 +17,14 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper.rb') -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.dirname(__FILE__) + "../../../spec_helper.rb") +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "Linux kernel plugin" do - test_plugin([ "kernel" ], [ "uname", "env" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "kernel" => { "os" => "GNU/Linux" }}) + test_plugin([ "kernel" ], %w{uname env}) do |p| + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "kernel" => { "os" => "GNU/Linux" } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "kernel" => { "os" => "GNU/Linux" }}) + { "kernel" => { "os" => "GNU/Linux" } }) end end diff --git a/platform_simulation_specs/plugins/lua_spec.rb b/platform_simulation_specs/plugins/lua_spec.rb index dd14dc5c..59f4d038 100644 --- a/platform_simulation_specs/plugins/lua_spec.rb +++ b/platform_simulation_specs/plugins/lua_spec.rb @@ -18,21 +18,20 @@ # limitations under the License. # - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin lua" do - test_plugin([ "languages", "lua" ], [ "lua" ]) do | p | - p.test([ "centos-6.4" ], ["x86", "x64"], [[], ["lua"]], - { "languages" => { "lua" => { "version" => "5.1.4" }}}) - p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "lua" => nil }}) + test_plugin(%w{languages lua}, [ "lua" ]) do |p| + p.test([ "centos-6.4" ], %w{x86 x64}, [[], ["lua"]], + { "languages" => { "lua" => { "version" => "5.1.4" } } }) + p.test([ "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "lua" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "lua" => nil }}) - p.test([ "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "lua" ]], - { "languages" => { "lua" => { "version" => "5.1.4" }}}) + { "languages" => { "lua" => nil } }) + p.test([ "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[ "lua" ]], + { "languages" => { "lua" => { "version" => "5.1.4" } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [["lua"]], - { "languages" => { "lua" => { "version" => "5.1.5" }}}) + { "languages" => { "lua" => { "version" => "5.1.5" } } }) end end diff --git a/platform_simulation_specs/plugins/nodejs_spec.rb b/platform_simulation_specs/plugins/nodejs_spec.rb index 042ecadb..fda9d5ff 100644 --- a/platform_simulation_specs/plugins/nodejs_spec.rb +++ b/platform_simulation_specs/plugins/nodejs_spec.rb @@ -18,18 +18,18 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin nodejs" do - test_plugin([ "languages", "nodejs" ], [ "node" ]) do | p | - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "nodejs" => nil }}) + test_plugin(%w{languages nodejs}, [ "node" ]) do |p| + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "nodejs" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "nodejs" => nil }}) - p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[ "nodejs" ]], - { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) + { "languages" => { "nodejs" => nil } }) + p.test([ "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[ "nodejs" ]], + { "languages" => { "nodejs" => { "version" => "0.10.2" } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "nodejs" ]], - { "languages" => { "nodejs" => { "version" => "0.10.2" }}}) + { "languages" => { "nodejs" => { "version" => "0.10.2" } } }) end end diff --git a/platform_simulation_specs/plugins/perl_spec.rb b/platform_simulation_specs/plugins/perl_spec.rb index 69612d90..aa851796 100644 --- a/platform_simulation_specs/plugins/perl_spec.rb +++ b/platform_simulation_specs/plugins/perl_spec.rb @@ -17,26 +17,26 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin perl" do - test_plugin([ "languages", "perl" ], [ "perl" ]) do | p | + test_plugin(%w{languages perl}, [ "perl" ]) do |p| p.test([ "centos-5.9" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "i386-linux-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "i386-linux-thread-multi" } } }) p.test([ "centos-5.9" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "x86_64-linux-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.8.8", "archname" => "x86_64-linux-thread-multi" } } }) p.test([ "centos-6.4" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i386-linux-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i386-linux-thread-multi" } } }) p.test([ "centos-6.4" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-thread-multi" } } }) p.test([ "ubuntu-10.04" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i486-linux-gnu-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "i486-linux-gnu-thread-multi" } } }) p.test([ "ubuntu-10.04" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-gnu-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.10.1", "archname" => "x86_64-linux-gnu-thread-multi" } } }) p.test([ "ubuntu-12.04" ], [ "x86" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "i686-linux-gnu-thread-multi-64int" }}}) + { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "i686-linux-gnu-thread-multi-64int" } } }) p.test([ "ubuntu-12.04", "ubuntu-13.04" ], [ "x64" ], [[], [ "perl" ]], - { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "x86_64-linux-gnu-thread-multi" }}}) + { "languages" => { "perl" => { "version" => "5.14.2", "archname" => "x86_64-linux-gnu-thread-multi" } } }) end end diff --git a/platform_simulation_specs/plugins/php_spec.rb b/platform_simulation_specs/plugins/php_spec.rb index e6094637..6e3ecb59 100644 --- a/platform_simulation_specs/plugins/php_spec.rb +++ b/platform_simulation_specs/plugins/php_spec.rb @@ -18,22 +18,22 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin php" do - test_plugin([ "languages", "php" ], [ "php" ]) do | p | - p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], [ "x86", "x64" ], [[]], - { "languages" => { "php" => nil }}) + test_plugin(%w{languages php}, [ "php" ]) do |p| + p.test([ "centos-5.9", "centos-6.4", "ubuntu-10.04", "ubuntu-12.04" ], %w{x86 x64}, [[]], + { "languages" => { "php" => nil } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[]], - { "languages" => { "php" => nil }}) - p.test([ "centos-5.9", "centos-6.4" ], [ "x86", "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.3" }}}) - p.test([ "ubuntu-10.04" ], ["x86", "x64"], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.2-1ubuntu4.20" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.3.10-1ubuntu3.7" }}}) + { "languages" => { "php" => nil } }) + p.test([ "centos-5.9", "centos-6.4" ], %w{x86 x64}, [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.3" } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.2-1ubuntu4.20" } } }) + p.test([ "ubuntu-12.04" ], %w{x86 x64}, [[ "php" ]], + { "languages" => { "php" => { "version" => "5.3.10-1ubuntu3.7" } } }) p.test([ "ubuntu-13.04" ], [ "x64" ], [[ "php" ]], - { "languages" => { "php" => { "version" => "5.4.9-4ubuntu2.2" }}}) + { "languages" => { "php" => { "version" => "5.4.9-4ubuntu2.2" } } }) end end diff --git a/platform_simulation_specs/plugins/python_spec.rb b/platform_simulation_specs/plugins/python_spec.rb index f4d58d4c..d34ce105 100644 --- a/platform_simulation_specs/plugins/python_spec.rb +++ b/platform_simulation_specs/plugins/python_spec.rb @@ -17,21 +17,20 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path( File.join( File.dirname( __FILE__ ), '..', 'common', 'ohai_plugin_common.rb' )) +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require File.expand_path( File.join( File.dirname( __FILE__ ), "..", "common", "ohai_plugin_common.rb" )) describe Ohai::System, "plugin python" do - test_plugin([ "languages", "python" ], [ "python" ]) do | p | - p.test([ "centos-5.9" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.4.3" }}}) - p.test([ "centos-6.4" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.6.6" }}}) - p.test([ "ubuntu-10.04" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.6.5" }}}) - p.test([ "ubuntu-12.04" ], [ "x86", "x64" ], [[], [ "python" ]], - { "languages" => { "python" => { "version" => "2.7.3"}}}) + test_plugin(%w{languages python}, [ "python" ]) do |p| + p.test([ "centos-5.9" ], %w{x86 x64}, [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.4.3" } } }) + p.test([ "centos-6.4" ], %w{x86 x64}, [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.6.6" } } }) + p.test([ "ubuntu-10.04" ], %w{x86 x64}, [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.6.5" } } }) + p.test([ "ubuntu-12.04" ], %w{x86 x64}, [[], [ "python" ]], + { "languages" => { "python" => { "version" => "2.7.3" } } }) p.test([ "ubuntu-13.04" ], ["x64"], [[], ["python"]], - { "languages" => { "python" => { "version" => "2.7.4"}}}) + { "languages" => { "python" => { "version" => "2.7.4" } } }) end end diff --git a/platform_simulation_specs/tools/grab_data.rb b/platform_simulation_specs/tools/grab_data.rb index 93ae56d0..662c874d 100644 --- a/platform_simulation_specs/tools/grab_data.rb +++ b/platform_simulation_specs/tools/grab_data.rb @@ -25,12 +25,12 @@ ## the data in that file as appropriate. ## -require 'yaml' -require 'set' -require 'mixlib/shellout' -require 'mixlib/cli' -require 'optparse' -require File.expand_path(File.dirname(__FILE__) + '/../spec/unit/path/ohai_plugin_common.rb') +require "yaml" +require "set" +require "mixlib/shellout" +require "mixlib/cli" +require "optparse" +require File.expand_path(File.dirname(__FILE__) + "/../spec/unit/path/ohai_plugin_common.rb") #get options class MyCLI @@ -86,12 +86,12 @@ env ||= [] # collect output results = params.map do |p| - m = Mixlib::ShellOut.new(cmd + ' ' + p) + m = Mixlib::ShellOut.new(cmd + " " + p) begin m.run_command - {:env => env, :params => p, :stdout => m.stdout, :stderr => m.stderr, :exit_status => m.exitstatus } + { :env => env, :params => p, :stdout => m.stdout, :stderr => m.stderr, :exit_status => m.exitstatus } rescue Errno::ENOENT - {:env => env, :params => p, :stdout => '', :stderr => 'command not found', :exit_status => 127 } + { :env => env, :params => p, :stdout => "", :stderr => "command not found", :exit_status => 127 } end end diff --git a/spec/functional/application_spec.rb b/spec/functional/application_spec.rb index ea9803ce..5c98e6ff 100644 --- a/spec/functional/application_spec.rb +++ b/spec/functional/application_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require_relative '../spec_helper' +require_relative "../spec_helper" -require 'ohai/application' +require "ohai/application" -RSpec.describe 'Ohai::Application' do +RSpec.describe "Ohai::Application" do let(:app) { Ohai::Application.new } let(:argv) { [] } @@ -37,12 +37,12 @@ RSpec.describe 'Ohai::Application' do describe '#configure_ohai' do - let(:config_content) { '' } - let(:config_dir) { Dir.mktmpdir('.chef') } - let(:config_location) { File.join(config_dir, 'config.rb') } + let(:config_content) { "" } + let(:config_dir) { Dir.mktmpdir(".chef") } + let(:config_location) { File.join(config_dir, "config.rb") } before(:each) do - File.open(config_location, 'w+') do |f| + File.open(config_location, "w+") do |f| f.write(config_content) end end @@ -51,13 +51,13 @@ RSpec.describe 'Ohai::Application' do FileUtils.rm_rf(config_dir) end - context 'when a configuration file is provided as a command line option' do + context "when a configuration file is provided as a command line option" do - let(:argv) { [ '-c', config_location + '.oops' ] } + let(:argv) { [ "-c", config_location + ".oops" ] } - context 'and the configuration file does not exist' do + context "and the configuration file does not exist" do - it 'logs an error and terminates the application' do + it "logs an error and terminates the application" do expect(STDERR).to receive(:puts).with(/FATAL:/) expect(Ohai::Log).to receive(:fatal). with(/Specified config file #{argv[1]} does not exist/) @@ -66,33 +66,33 @@ RSpec.describe 'Ohai::Application' do end end - context 'when a workstation configuration file exists' do + context "when a workstation configuration file exists" do - let(:config_content) { 'ohai.disabled_plugins = [ :Foo, :Baz ]' } + let(:config_content) { "ohai.disabled_plugins = [ :Foo, :Baz ]" } # env['KNIFE_HOME']/config.rb is the first config file the workstation # config loader looks for: # https://github.com/chef/chef/blob/master/chef-config/lib/chef-config/workstation_config_loader.rb#L102 - let(:env) { { 'KNIFE_HOME' => config_dir } } + let(:env) { { "KNIFE_HOME" => config_dir } } before(:each) do allow_any_instance_of(ChefConfig::WorkstationConfigLoader). to receive(:env).and_return(env) end - it 'loads the workstation configuration file' do + it "loads the workstation configuration file" do app.configure_ohai expect(Ohai.config[:disabled_plugins]).to eq([ :Foo, :Baz ]) end end - context 'when the configuration file contains deprecated config options' do + context "when the configuration file contains deprecated config options" do # For the purpose of these tests it doesn't matter if the configuration # file was specified via command line or discovered on the local # workstation. It's easier if we pass the configuration file as a cli # argument (there's less to stub). - let(:argv) { [ '-c', config_location ] } + let(:argv) { [ "-c", config_location ] } let(:config_content) do <<-CONFIG @@ -108,11 +108,11 @@ CONFIG let(:log_level) { :debug } - let(:log_location) { 'path/to/log' } + let(:log_location) { "path/to/log" } - let(:plugin_path) { '/path/to/plugins' } + let(:plugin_path) { "/path/to/plugins" } - it 'logs warnings for deprecated top-level options' do + it "logs warnings for deprecated top-level options" do # deprecation warnings for options need to be stubbed in the order # they are received, in this case it's the order they appear in the # configuration file. @@ -125,17 +125,17 @@ CONFIG end end - context 'when the configuration file has a syntax error' do + context "when the configuration file has a syntax error" do # For the purpose of these tests it doesn't matter if the configuration # file was specified via command line or discovered on the local # workstation. It's easier if we pass the configuration file as a cli # argument (there's less to stub). - let(:argv) { [ '-c', config_location ] } + let(:argv) { [ "-c", config_location ] } let(:config_content) { 'config_location "blaaaaa' } - it 'logs an error and terminates the application' do + it "logs an error and terminates the application" do expect(STDERR).to receive(:puts).with(/FATAL:/) expect(Ohai::Log).to receive(:fatal). with(/You have invalid ruby syntax in your config file/) diff --git a/spec/functional/loader_spec.rb b/spec/functional/loader_spec.rb index bb9683e3..5053ad6f 100644 --- a/spec/functional/loader_spec.rb +++ b/spec/functional/loader_spec.rb @@ -33,7 +33,7 @@ Ohai.plugin(:Foo) do provides 'foo' end EOF - File.open(File.join(plugin_directory, "foo.rb"), 'w+') do |f| + File.open(File.join(plugin_directory, "foo.rb"), "w+") do |f| f.write(plugin_content) end end diff --git a/spec/functional/plugins/powershell_spec.rb b/spec/functional/plugins/powershell_spec.rb index 34a8b61e..865bb850 100644 --- a/spec/functional/plugins/powershell_spec.rb +++ b/spec/functional/plugins/powershell_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -describe Ohai::System, 'languages plugin' do +describe Ohai::System, "languages plugin" do VERSION_MATCHING_REGEX = /^(?:[\d]+\.)+[\d]+$/ - describe 'powershell plugin', :windows_only do + describe "powershell plugin", :windows_only do RSpec.shared_examples "a version looking thing" do - it 'should be present' do + it "should be present" do expect(subject).not_to be_nil end - it 'should look like a version' do + it "should look like a version" do expect(subject).to match(VERSION_MATCHING_REGEX) end end @@ -37,42 +37,42 @@ describe Ohai::System, 'languages plugin' do subject { @plugin[:languages][:powershell] } - it 'should have information about powershell' do + it "should have information about powershell" do expect(subject).not_to be_nil end describe :version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :ws_man_stack_version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :serialization_version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :clr_version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :build_version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :remoting_protocol_version do subject { @plugin.languages[:powershell][described_class] } - it_behaves_like 'a version looking thing' + it_behaves_like "a version looking thing" end describe :compatible_versions do - it 'has compatible_versions that look like versions' do + it "has compatible_versions that look like versions" do @plugin.languages[:powershell][described_class].each do |version| expect(version).to match(VERSION_MATCHING_REGEX) end diff --git a/spec/functional/plugins/root_group_spec.rb b/spec/functional/plugins/root_group_spec.rb index bf87b110..781582d8 100644 --- a/spec/functional/plugins/root_group_spec.rb +++ b/spec/functional/plugins/root_group_spec.rb @@ -18,13 +18,13 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -describe Ohai::System, 'root_group plugin' do +describe Ohai::System, "root_group plugin" do let(:plugin) { get_plugin("root_group") } - describe 'windows platform', :windows_only do - let (:wmi) { wmi = WmiLite::Wmi.new } + describe "windows platform", :windows_only do + let (:wmi) { wmi = WmiLite::Wmi.new } it 'should return the system\'s administrators (root) group' do # Notethat the Win32_Group WMI provider can be slow if your @@ -33,7 +33,7 @@ describe Ohai::System, 'root_group plugin' do # something to watch if you run this test in such an environment. groups = wmi.query("select * from Win32_Group where sid = 'S-1-5-32-544'") expect(groups.length).to eq(1) - administrators_group = groups[0]['name'].downcase + administrators_group = groups[0]["name"].downcase plugin.run expect(plugin[:root_group].downcase).to be == administrators_group end diff --git a/spec/ohai_spec.rb b/spec/ohai_spec.rb index a8df8fcf..376356b0 100644 --- a/spec/ohai_spec.rb +++ b/spec/ohai_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/spec_helper.rb") describe Ohai do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8d561ea8..5f5491ee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,16 +1,16 @@ -require 'rspec' -require 'rspec/collection_matchers' +require "rspec" +require "rspec/collection_matchers" # require 'pry-debugger' # require 'pry-stack_explorer' $:.unshift(File.expand_path("../..", __FILE__)) -$:.unshift(File.dirname(__FILE__) + '/../lib') +$:.unshift(File.dirname(__FILE__) + "/../lib") -require 'spec/support/platform_helpers' -require 'spec/support/integration_helper' -require 'wmi-lite' -require 'ohai' +require "spec/support/platform_helpers" +require "spec/support/integration_helper" +require "wmi-lite" +require "ohai" Ohai.config[:log_level] = :error PLUGIN_PATH = File.expand_path("../../lib/ohai/plugins", __FILE__) @@ -112,8 +112,8 @@ RSpec.configure do |config| config.filter_run_excluding :unix_only => true unless unix? config.filter_run_excluding :ruby_18_only => true unless ruby_18? config.filter_run_excluding :ruby_19_only => true unless ruby_19? - config.filter_run_excluding :requires_root => true unless ENV['USER'] == 'root' - config.filter_run_excluding :requires_unprivileged_user => true if ENV['USER'] == 'root' + config.filter_run_excluding :requires_root => true unless ENV["USER"] == "root" + config.filter_run_excluding :requires_unprivileged_user => true if ENV["USER"] == "root" config.run_all_when_everything_filtered = true diff --git a/spec/support/integration_helper.rb b/spec/support/integration_helper.rb index 56f179d2..ce61b3f1 100644 --- a/spec/support/integration_helper.rb +++ b/spec/support/integration_helper.rb @@ -1,11 +1,11 @@ -require 'tmpdir' +require "tmpdir" -module IntegrationSupport +module IntegrationSupport def when_plugins_directory(description, &block) context "When the plugins directory #{description}" do before(:each) do - @plugins_directory = Dir.mktmpdir('ohai-plugins') + @plugins_directory = Dir.mktmpdir("ohai-plugins") end after(:each) do @@ -21,12 +21,12 @@ module IntegrationSupport def with_plugin(plugin_path, contents) filename = path_to(plugin_path) dir = File.dirname(filename) - FileUtils.mkdir_p(dir) unless dir == '.' - File.open(filename, 'w') do |file| + FileUtils.mkdir_p(dir) unless dir == "." + File.open(filename, "w") do |file| file.write(contents) end end - + def path_to(plugin_path) File.expand_path(plugin_path, @plugins_directory) end @@ -36,7 +36,7 @@ module IntegrationSupport with_plugin(plugin_path, contents) end end - + instance_eval(&block) end end diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 558817d7..4a4cb91d 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -28,4 +28,4 @@ def freebsd? !!(RUBY_PLATFORM =~ /freebsd/) end -DEV_NULL = windows? ? 'NUL' : '/dev/null' +DEV_NULL = windows? ? "NUL" : "/dev/null" diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 25a92824..0f45786e 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require_relative '../spec_helper' +require_relative "../spec_helper" -require 'ohai/application' +require "ohai/application" -RSpec.describe 'Ohai::Application' do +RSpec.describe "Ohai::Application" do let(:argv) { [] } let(:app) { Ohai::Application.new } @@ -35,12 +35,12 @@ RSpec.describe 'Ohai::Application' do end describe '#configure_ohai' do - describe 'loading configuration from a file' do - let(:config_file) { '/local/workstation/config' } - let(:config_loader) { instance_double('ChefConfig::WorkstationConfigLoader') } + describe "loading configuration from a file" do + let(:config_file) { "/local/workstation/config" } + let(:config_loader) { instance_double("ChefConfig::WorkstationConfigLoader") } - context 'when specified on the command line' do - let(:argv) { [ '-c', config_file ] } + context "when specified on the command line" do + let(:argv) { [ "-c", config_file ] } before(:each) do if windows? @@ -54,13 +54,13 @@ RSpec.describe 'Ohai::Application' do end end - it 'loads the configuration file' do + it "loads the configuration file" do expect(config_loader).to receive(:load) app.configure_ohai end - context 'when the configuration file does not exist' do - it 'terminates the application' do + context "when the configuration file does not exist" do + it "terminates the application" do expect(config_loader).to receive(:load).and_raise(ChefConfig::ConfigurationError) expect(Ohai::Application).to receive(:fatal!) app.configure_ohai @@ -68,25 +68,25 @@ RSpec.describe 'Ohai::Application' do end end - context 'when a local workstation config exists' do + context "when a local workstation config exists" do before(:each) do expect(ChefConfig::WorkstationConfigLoader).to receive(:new). with(nil, Ohai::Log). and_return(config_loader) end - it 'loads the configuration file' do + it "loads the configuration file" do expect(config_loader).to receive(:load) app.configure_ohai end end end - context 'when CLI options are provided' do - let(:argv) { [ '-d', directory ] } - let(:directory) { '/some/fantastic/plugins' } + context "when CLI options are provided" do + let(:argv) { [ "-d", directory ] } + let(:directory) { "/some/fantastic/plugins" } - it 'does not generate deprecated config warnings for cli options' do + it "does not generate deprecated config warnings for cli options" do expect(Ohai::Log).to_not receive(:warn). with(/Ohai::Config\[:directory\] is deprecated/) app.configure_ohai diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 5cb591b2..4be23ce8 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require_relative '../spec_helper' +require_relative "../spec_helper" -require 'ohai/config' +require "ohai/config" RSpec.describe Ohai::Config do diff --git a/spec/unit/dsl/plugin_spec.rb b/spec/unit/dsl/plugin_spec.rb index 07873449..698e3f1b 100644 --- a/spec/unit/dsl/plugin_spec.rb +++ b/spec/unit/dsl/plugin_spec.rb @@ -124,33 +124,33 @@ end describe Ohai::DSL::Plugin::VersionVII do it "should not modify the plugin name when the plugin is named correctly" do - plugin = Ohai.plugin(:FunkyVALIDpluginName) { }.new({ }) + plugin = Ohai.plugin(:FunkyVALIDpluginName) {}.new({}) expect(plugin.name).to eql(:FunkyVALIDpluginName) end describe "when the plugin is named incorrectly" do context "because the plugin name doesn't start with a capital letter" do it "should raise an Ohai::Exceptions::InvalidPluginName exception" do - expect{ Ohai.plugin(:badName) { } }.to raise_error(Ohai::Exceptions::InvalidPluginName, /badName is not a valid plugin name/) + expect { Ohai.plugin(:badName) {} }.to raise_error(Ohai::Exceptions::InvalidPluginName, /badName is not a valid plugin name/) end end context "because the plugin name contains an underscore" do it "should raise an Ohai::Exceptions::InvalidPluginName exception" do - expect{ Ohai.plugin(:Bad_Name) { } }.to raise_error(Ohai::Exceptions::InvalidPluginName, /Bad_Name is not a valid plugin name/) + expect { Ohai.plugin(:Bad_Name) {} }.to raise_error(Ohai::Exceptions::InvalidPluginName, /Bad_Name is not a valid plugin name/) end end context "because the plugin name isn't a symbol" do it "should raise an Ohai::Exceptions::InvalidPluginName exception" do - expect{ Ohai.plugin(1138) { } }.to raise_error(Ohai::Exceptions::InvalidPluginName, /1138 is not a valid plugin name/) + expect { Ohai.plugin(1138) {} }.to raise_error(Ohai::Exceptions::InvalidPluginName, /1138 is not a valid plugin name/) end end end describe "#version" do it "should save the plugin version as :version7" do - plugin = Ohai.plugin(:Test) { } + plugin = Ohai.plugin(:Test) {} expect(plugin.version).to eql(:version7) end end @@ -163,7 +163,7 @@ describe Ohai::DSL::Plugin::VersionVII do it "should collect a list of attributes" do plugin = Ohai.plugin(:Test) { provides("one", "two", "three") } - expect(plugin.provides_attrs).to eql(["one", "two", "three"]) + expect(plugin.provides_attrs).to eql(%w{one two three}) end it "should collect from multiple provides statements" do @@ -172,19 +172,19 @@ describe Ohai::DSL::Plugin::VersionVII do provides("two", "three") provides("four") } - expect(plugin.provides_attrs).to eql(["one", "two", "three", "four"]) + expect(plugin.provides_attrs).to eql(%w{one two three four}) end it "should collect attributes across multiple plugin files" do plugin = Ohai.plugin(:Test) { provides("one") } plugin = Ohai.plugin(:Test) { provides("two", "three") } - expect(plugin.provides_attrs).to eql(["one", "two", "three"]) + expect(plugin.provides_attrs).to eql(%w{one two three}) end it "should collect unique attributes" do plugin = Ohai.plugin(:Test) { provides("one") } plugin = Ohai.plugin(:Test) { provides("one", "two") } - expect(plugin.provides_attrs).to eql(["one", "two"]) + expect(plugin.provides_attrs).to eql(%w{one two}) end end @@ -196,7 +196,7 @@ describe Ohai::DSL::Plugin::VersionVII do it "should collect a list of dependencies" do plugin = Ohai.plugin(:Test) { depends("one", "two", "three") } - expect(plugin.depends_attrs).to eql(["one", "two", "three"]) + expect(plugin.depends_attrs).to eql(%w{one two three}) end it "should collect from multiple depends statements" do @@ -205,35 +205,35 @@ describe Ohai::DSL::Plugin::VersionVII do depends("two", "three") depends("four") } - expect(plugin.depends_attrs).to eql(["one", "two", "three", "four"]) + expect(plugin.depends_attrs).to eql(%w{one two three four}) end it "should collect dependencies across multiple plugin files" do plugin = Ohai.plugin(:Test) { depends("one") } plugin = Ohai.plugin(:Test) { depends("two", "three") } - expect(plugin.depends_attrs).to eql(["one", "two", "three"]) + expect(plugin.depends_attrs).to eql(%w{one two three}) end it "should collect unique attributes" do plugin = Ohai.plugin(:Test) { depends("one") } plugin = Ohai.plugin(:Test) { depends("one", "two") } - expect(plugin.depends_attrs).to eql(["one", "two"]) + expect(plugin.depends_attrs).to eql(%w{one two}) end end describe "#collect_data" do it "should save as :default if no platform is given" do - plugin = Ohai.plugin(:Test) { collect_data { } } + plugin = Ohai.plugin(:Test) { collect_data {} } expect(plugin.data_collector).to have_key(:default) end it "should save a single given platform" do - plugin = Ohai.plugin(:Test) { collect_data(:ubuntu) { } } + plugin = Ohai.plugin(:Test) { collect_data(:ubuntu) {} } expect(plugin.data_collector).to have_key(:ubuntu) end it "should save a list of platforms" do - plugin = Ohai.plugin(:Test) { collect_data(:freebsd, :netbsd, :openbsd) { } } + plugin = Ohai.plugin(:Test) { collect_data(:freebsd, :netbsd, :openbsd) {} } [:freebsd, :netbsd, :openbsd].each do |platform| expect(plugin.data_collector).to have_key(platform) end @@ -241,9 +241,9 @@ describe Ohai::DSL::Plugin::VersionVII do it "should save multiple collect_data blocks" do plugin = Ohai.plugin(:Test) { - collect_data { } - collect_data(:windows) { } - collect_data(:darwin) { } + collect_data {} + collect_data(:windows) {} + collect_data(:darwin) {} } [:darwin, :default, :windows].each do |platform| expect(plugin.data_collector).to have_key(platform) @@ -251,8 +251,8 @@ describe Ohai::DSL::Plugin::VersionVII do end it "should save platforms across multiple plugins" do - plugin = Ohai.plugin(:Test) { collect_data { } } - plugin = Ohai.plugin(:Test) { collect_data(:aix, :sigar) { } } + plugin = Ohai.plugin(:Test) { collect_data {} } + plugin = Ohai.plugin(:Test) { collect_data(:aix, :sigar) {} } [:aix, :default, :sigar].each do |platform| expect(plugin.data_collector).to have_key(platform) end @@ -261,17 +261,17 @@ describe Ohai::DSL::Plugin::VersionVII do it "should fail a platform has already been defined in the same plugin" do expect { Ohai.plugin(:Test) { - collect_data { } - collect_data { } + collect_data {} + collect_data {} } }.to raise_error(Ohai::Exceptions::IllegalPluginDefinition, /collect_data already defined/) end it "should fail if a platform has already been defined in another plugin file" do - Ohai.plugin(:Test) { collect_data { } } + Ohai.plugin(:Test) { collect_data {} } expect { Ohai.plugin(:Test) { - collect_data { } + collect_data {} } }.to raise_error(Ohai::Exceptions::IllegalPluginDefinition, /collect_data already defined/) end @@ -295,7 +295,7 @@ describe Ohai::DSL::Plugin::VersionVII do describe "#configuration" do let(:plugin) do - klass = Ohai.plugin(camel_name) { } + klass = Ohai.plugin(camel_name) {} klass.new({}) end @@ -325,7 +325,7 @@ describe Ohai::DSL::Plugin::VersionVII do end it "returns nil when the suboption is not configured" do - Ohai.config[:plugin][snake_name][:foo] = { } + Ohai.config[:plugin][snake_name][:foo] = {} expect(plugin.configuration(:foo, :bar)).to eq(nil) end @@ -376,7 +376,7 @@ end describe Ohai::DSL::Plugin::VersionVI do describe "#version" do it "should save the plugin version as :version6" do - plugin = Class.new(Ohai::DSL::Plugin::VersionVI) { } + plugin = Class.new(Ohai::DSL::Plugin::VersionVI) {} expect(plugin.version).to eql(:version6) end end diff --git a/spec/unit/hints_spec.rb b/spec/unit/hints_spec.rb index fa3b35f4..88556528 100644 --- a/spec/unit/hints_spec.rb +++ b/spec/unit/hints_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe "Ohai::Hints" do # We are using the plugins directory infrastructure to test hints @@ -54,11 +54,11 @@ EOF end it "hint? should return the data for full hints" do - expect(Ohai::Hints.hint?("cloud")).to eq({"name" => "circus"}) + expect(Ohai::Hints.hint?("cloud")).to eq({ "name" => "circus" }) end it "hint? should return empty hash for empty hints" do - expect(Ohai::Hints.hint?("cloud_empty")).to eq({ }) + expect(Ohai::Hints.hint?("cloud_empty")).to eq({}) end end diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb index f36c101a..f211a7b1 100644 --- a/spec/unit/loader_spec.rb +++ b/spec/unit/loader_spec.rb @@ -17,13 +17,13 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::Loader do extend IntegrationSupport let(:loader) { Ohai::Loader.new(ohai) } - let(:ohai) { double('Ohai::System', :data => Mash.new, :provides_map => provides_map) } + let(:ohai) { double("Ohai::System", :data => Mash.new, :provides_map => provides_map) } let(:provides_map) { Ohai::ProvidesMap.new } describe "#initialize" do @@ -150,7 +150,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("extra_s.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("extra_s.rb")) }.not_to raise_error end end @@ -161,7 +161,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("no_method.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("no_method.rb")) }.not_to raise_error end end @@ -172,7 +172,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("illegal_def.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("illegal_def.rb")) }.not_to raise_error end end @@ -183,7 +183,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("unexpected_error.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("unexpected_error.rb")) }.not_to raise_error end end @@ -194,7 +194,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("bad_symbol.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("bad_symbol.rb")) }.not_to raise_error end end @@ -205,7 +205,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("no_end.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("no_end.rb")) }.not_to raise_error end end @@ -216,7 +216,7 @@ EOF end it "does not raise an error" do - expect{ loader.load_plugin(path_to("bad_name.rb")) }.not_to raise_error + expect { loader.load_plugin(path_to("bad_name.rb")) }.not_to raise_error end end end diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index 7b1bc0dd..97180d06 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::Mixin::Command, "popen4" do break if RUBY_PLATFORM =~ /(win|w)32$/ @@ -30,7 +30,7 @@ describe Ohai::Mixin::Command, "popen4" do end it "should respect locale when specified explicitly" do - Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => {"LC_ALL" => "es"}) do |pid, stdin, stdout, stderr| + Ohai::Mixin::Command.popen4("echo $LC_ALL", :environment => { "LC_ALL" => "es" }) do |pid, stdin, stdout, stderr| stdin.close expect(stdout.read.strip).to eq("es") end @@ -52,14 +52,14 @@ describe Ohai::Mixin::Command, "popen4" do it "should force encode the string to UTF-8" do extend Ohai::Mixin::Command - snowy = run_command(:command => ("echo '" + ('☃' * 8096) + "'"))[1] + snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1] expect(snowy.encoding).to eq(Encoding::UTF_8) end end it "should force encode the string to UTF-8" do extend Ohai::Mixin::Command - snowy = run_command(:command => ("echo '" + ('☃' * 8096) + "'"))[1] + snowy = run_command(:command => ("echo '" + ("☃" * 8096) + "'"))[1] expect(snowy.encoding).to eq(Encoding::UTF_8) end end @@ -72,7 +72,7 @@ describe Ohai::Mixin::Command, "popen4" do created_procs = 0 100.times do begin - Ohai::Mixin::Command.popen4("/bin/this-is-not-a-real-command") {|p,i,o,e| nil } + Ohai::Mixin::Command.popen4("/bin/this-is-not-a-real-command") { |p, i, o, e| nil } rescue Ohai::Exceptions::Exec created_procs += 1 end diff --git a/spec/unit/mixin/ec2_metadata_spec.rb b/spec/unit/mixin/ec2_metadata_spec.rb index e65fe5c6..002b42c2 100644 --- a/spec/unit/mixin/ec2_metadata_spec.rb +++ b/spec/unit/mixin/ec2_metadata_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'ohai/mixin/ec2_metadata' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "ohai/mixin/ec2_metadata" describe Ohai::Mixin::Ec2Metadata do let(:mixin) { @@ -49,7 +49,7 @@ describe Ohai::Mixin::Ec2Metadata do let(:response) { double("Net::HTTP Response", :body => "2020-01-01\nUnsupported", :code => "200") } it "raises an error" do - expect { mixin.best_api_version}.to raise_error(RuntimeError) + expect { mixin.best_api_version }.to raise_error(RuntimeError) end end @@ -58,7 +58,7 @@ describe Ohai::Mixin::Ec2Metadata do let(:response) { double("Net::HTTP Response", :code => "404") } it "returns 'latest' as the version" do - expect(mixin.best_api_version).to eq('latest') + expect(mixin.best_api_version).to eq("latest") end end @@ -66,7 +66,7 @@ describe Ohai::Mixin::Ec2Metadata do let(:response) { double("Net::HTTP Response", :body => "1.0\n2011-05-01\n2012-01-12\nUnsupported", :code => "418") } it "raises an error" do - expect { mixin.best_api_version}.to raise_error(RuntimeError) + expect { mixin.best_api_version }.to raise_error(RuntimeError) end end end @@ -76,7 +76,7 @@ describe Ohai::Mixin::Ec2Metadata do let(:response) { double("Net::HTTP Response", :body => "", :code => "418") } it "raises an error" do - expect { mixin.metadata_get('', '2012-01-12') }.to raise_error(RuntimeError) + expect { mixin.metadata_get("", "2012-01-12") }.to raise_error(RuntimeError) end end end diff --git a/spec/unit/mixin/softlayer_metadata_spec.rb b/spec/unit/mixin/softlayer_metadata_spec.rb index b36a38b8..f69ba0b2 100644 --- a/spec/unit/mixin/softlayer_metadata_spec.rb +++ b/spec/unit/mixin/softlayer_metadata_spec.rb @@ -17,9 +17,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'ohai/mixin/softlayer_metadata' - +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "ohai/mixin/softlayer_metadata" describe ::Ohai::Mixin::SoftlayerMetadata do @@ -33,39 +32,36 @@ describe ::Ohai::Mixin::SoftlayerMetadata do end def make_res(body) - double("response", {:body => body, :code => "200"}) + double("response", { :body => body, :code => "200" }) end - - context 'fetch_metadata' do + context "fetch_metadata" do it "riases error if softlayer api query results with error" do - http_mock = double('http', {:ssl_version= => true, :use_ssl= => true, :ca_file= => true}) + http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true }) allow(http_mock).to receive(:get).and_raise(StandardError.new("API return fake error")) - allow(::Net::HTTP).to receive(:new).with('api.service.softlayer.com', 443).and_return(http_mock) + allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock) expect(::Ohai::Log).to receive(:error).at_least(:once) - expect{mixin.fetch_metadata}.to raise_error(StandardError) + expect { mixin.fetch_metadata }.to raise_error(StandardError) end it "query api service" do - http_mock = double('http', {:ssl_version= => true, :use_ssl= => true, :ca_file= => true}) - allow(::Net::HTTP).to receive(:new).with('api.service.softlayer.com', 443).and_return(http_mock) - - expect(http_mock).to receive(:get).with(make_request('getFullyQualifiedDomainName.txt')).and_return(make_res('abc.host.org')).once - expect(http_mock).to receive(:get).with(make_request('getPrimaryBackendIpAddress.txt')).and_return(make_res('10.0.1.10')).once - expect(http_mock).to receive(:get).with(make_request('getPrimaryIpAddress.txt')).and_return(make_res('8.8.8.8')).once - expect(http_mock).to receive(:get).with(make_request('getId.txt')).and_return(make_res('1111')).once - expect(http_mock).to receive(:get).with(make_request('getDatacenter.txt')).and_return(make_res('dal05')).once + http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true }) + allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock) + expect(http_mock).to receive(:get).with(make_request("getFullyQualifiedDomainName.txt")).and_return(make_res("abc.host.org")).once + expect(http_mock).to receive(:get).with(make_request("getPrimaryBackendIpAddress.txt")).and_return(make_res("10.0.1.10")).once + expect(http_mock).to receive(:get).with(make_request("getPrimaryIpAddress.txt")).and_return(make_res("8.8.8.8")).once + expect(http_mock).to receive(:get).with(make_request("getId.txt")).and_return(make_res("1111")).once + expect(http_mock).to receive(:get).with(make_request("getDatacenter.txt")).and_return(make_res("dal05")).once metadata = mixin.fetch_metadata expect(metadata).not_to be_nil - expect(metadata["public_fqdn"]).to eq('abc.host.org') - expect(metadata["local_ipv4"]).to eq('10.0.1.10') - expect(metadata["instance_id"]).to eq('1111') - expect(metadata["region"]).to eq('dal05') - expect(metadata["public_ipv4"]).to eq('8.8.8.8') + expect(metadata["public_fqdn"]).to eq("abc.host.org") + expect(metadata["local_ipv4"]).to eq("10.0.1.10") + expect(metadata["instance_id"]).to eq("1111") + expect(metadata["region"]).to eq("dal05") + expect(metadata["public_ipv4"]).to eq("8.8.8.8") end end end - diff --git a/spec/unit/plugin_config_spec.rb b/spec/unit/plugin_config_spec.rb index 75b4f6f7..1391a2a5 100644 --- a/spec/unit/plugin_config_spec.rb +++ b/spec/unit/plugin_config_spec.rb @@ -15,9 +15,9 @@ # limitations under the License. # -require_relative '../spec_helper' +require_relative "../spec_helper" -require 'ohai/plugin_config' +require "ohai/plugin_config" describe "Ohai::PluginConfig" do @@ -56,7 +56,7 @@ describe "Ohai::PluginConfig" do { :bar0 => true, :bar1 => [ :baz0, :baz1, :baz2 ], - :bar2 => { :qux0 => true, :qux1 => false } + :bar2 => { :qux0 => true, :qux1 => false }, } } @@ -70,7 +70,7 @@ describe "Ohai::PluginConfig" do { :bar0 => true, "bar1" => [ :baz0, :baz1, :baz2 ], - :bar2 => { :qux0 => true, :qux1 => false } + :bar2 => { :qux0 => true, :qux1 => false }, } } @@ -84,7 +84,7 @@ describe "Ohai::PluginConfig" do { :bar0 => true, :bar1 => [ :baz0, :baz1, :baz2 ], - :bar2 => { :qux0 => true, "qux1" => false } + :bar2 => { :qux0 => true, "qux1" => false }, } } diff --git a/spec/unit/plugins/abort_spec.rb b/spec/unit/plugins/abort_spec.rb index b99647f1..6140419e 100644 --- a/spec/unit/plugins/abort_spec.rb +++ b/spec/unit/plugins/abort_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) -tmp = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp' +tmp = ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp" abortstr = < "f1000000c0338000", "size" => "77000" }) expect(@plugin[:kernel][:modules]["/usr/lib/drivers/cluster"]["data"]).to eq({ "address" => "f1000000c0390000", "size" => "1ec8c" }) - expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"]).to eq({ "address" => "6390000", "size" => "20000"}) - expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"]).to eq({ "address" => "63a0000", "size" => "ba8"}) + expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["text"]).to eq({ "address" => "6390000", "size" => "20000" }) + expect(@plugin[:kernel][:modules]["/usr/lib/drivers/if_en"]["data"]).to eq({ "address" => "63a0000", "size" => "ba8" }) end end diff --git a/spec/unit/plugins/aix/memory_spec.rb b/spec/unit/plugins/aix/memory_spec.rb index 80f893d3..cfe9862f 100644 --- a/spec/unit/plugins/aix/memory_spec.rb +++ b/spec/unit/plugins/aix/memory_spec.rb @@ -16,34 +16,34 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX memory plugin" do - before(:each) do + before(:each) do @plugin = get_plugin("aix/memory") allow(@plugin).to receive(:collect_os).and_return(:aix) allow(@plugin).to receive(:shell_out).with("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").and_return(mock_shell_out(0, " 513280.00 340034.17 173245.83 62535.17 230400.05 276950.14 70176.00\n", nil)) @swap_s = "allocated = 23887872 blocks used = 288912 blocks free = 23598960 blocks\n" - allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0,@swap_s, nil)) - end + allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, nil)) + end it "should get total memory" do @plugin.run - expect(@plugin['memory']['total']).to eql("#{513280 * 1024}kB") + expect(@plugin["memory"]["total"]).to eql("#{513280 * 1024}kB") end it "should get free memory" do @plugin.run - expect(@plugin['memory']['free']).to eql("#{173245.83.to_i * 1024}kB") + expect(@plugin["memory"]["free"]).to eql("#{173245.83.to_i * 1024}kB") end it "should get total swap" do @plugin.run - expect(@plugin['memory']['swap']['total']).to eql( "#{23887872 * 4}kB") + expect(@plugin["memory"]["swap"]["total"]).to eql( "#{23887872 * 4}kB") end it "should get free swap" do @plugin.run - expect(@plugin['memory']['swap']['free']).to eql( "#{23598960 * 4}kB") + expect(@plugin["memory"]["swap"]["free"]).to eql( "#{23598960 * 4}kB") end end diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index a6212ade..1007a868 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX network plugin" do @@ -94,15 +94,15 @@ ARP_AN end it "detects network information" do - expect(@plugin['network']).not_to be_nil + expect(@plugin["network"]).not_to be_nil end it "detects the interfaces" do - expect(@plugin['network']['interfaces'].keys.sort).to eq(["en0", "en1", "lo0"]) + expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 lo0}) end it "detects the ip addresses of the interfaces" do - expect(@plugin['network']['interfaces']['en0']['addresses'].keys).to include('172.29.174.58') + expect(@plugin["network"]["interfaces"]["en0"]["addresses"].keys).to include("172.29.174.58") end end @@ -124,11 +124,11 @@ ARP_AN end it "returns the default gateway of the system's network" do - expect(@plugin[:network][:default_gateway]).to eq('172.31.8.1') + expect(@plugin[:network][:default_gateway]).to eq("172.31.8.1") end it "returns the default interface of the system's network" do - expect(@plugin[:network][:default_interface]).to eq('en0') + expect(@plugin[:network][:default_interface]).to eq("en0") end end end @@ -155,42 +155,42 @@ ARP_AN describe "lsdev -Cc if" do it "detects the state of the interfaces in the system" do @plugin.run - expect(@plugin['network']['interfaces']['en0'][:state]).to eq("up") + expect(@plugin["network"]["interfaces"]["en0"][:state]).to eq("up") end describe "ifconfig interface" do it "detects the CHAIN network flag" do @plugin.run - expect(@plugin['network']['interfaces']['en0'][:flags]).to include('CHAIN') + expect(@plugin["network"]["interfaces"]["en0"][:flags]).to include("CHAIN") end it "detects the metric network flag" do @plugin.run - expect(@plugin['network']['interfaces']['en0'][:metric]).to eq('1') + expect(@plugin["network"]["interfaces"]["en0"][:metric]).to eq("1") end context "inet entries" do before do @plugin.run - @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.58"] + @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.58"] end it "detects the family" do - expect(@inet_entry[:family]).to eq('inet') + expect(@inet_entry[:family]).to eq("inet") end it "detects the netmask" do - expect(@inet_entry[:netmask]).to eq('255.255.192.0') + expect(@inet_entry[:netmask]).to eq("255.255.192.0") end it "detects the broadcast" do - expect(@inet_entry[:broadcast]).to eq('172.29.191.255') + expect(@inet_entry[:broadcast]).to eq("172.29.191.255") end it "detects all key-values" do - expect(@plugin['network']['interfaces']['en0'][:tcp_sendspace]).to eq("262144") - expect(@plugin['network']['interfaces']['en0'][:tcp_recvspace]).to eq("262144") - expect(@plugin['network']['interfaces']['en0'][:rfc1323]).to eq("1") + expect(@plugin["network"]["interfaces"]["en0"][:tcp_sendspace]).to eq("262144") + expect(@plugin["network"]["interfaces"]["en0"][:tcp_recvspace]).to eq("262144") + expect(@plugin["network"]["interfaces"]["en0"][:rfc1323]).to eq("1") end # For an output with no netmask like inet 172.29.174.59 broadcast 172.29.191.255 @@ -200,13 +200,13 @@ ARP_AN end it "detects the default prefixlen" do - @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"] - expect(@inet_entry[:prefixlen]).to eq('32') + @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"] + expect(@inet_entry[:prefixlen]).to eq("32") end it "detects the default netmask" do - @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["172.29.174.59"] - expect(@inet_entry[:netmask]).to eq('255.255.255.255') + @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["172.29.174.59"] + expect(@inet_entry[:netmask]).to eq("255.255.255.255") end end end @@ -214,15 +214,15 @@ ARP_AN context "inet6 entries" do before do @plugin.run - @inet_entry = @plugin['network']['interfaces']['en0'][:addresses]["::1"] + @inet_entry = @plugin["network"]["interfaces"]["en0"][:addresses]["::1"] end it "detects the prefixlen" do - expect(@inet_entry[:prefixlen]).to eq('0') + expect(@inet_entry[:prefixlen]).to eq("0") end it "detects the family" do - expect(@inet_entry[:family]).to eq('inet6') + expect(@inet_entry[:family]).to eq("inet6") end end end @@ -230,10 +230,10 @@ ARP_AN context "entstat -d interface" do before do @plugin.run - @inet_interface_addresses = @plugin['network']['interfaces']['en0'][:addresses]["BE:42:80:00:B0:05"] + @inet_interface_addresses = @plugin["network"]["interfaces"]["en0"][:addresses]["BE:42:80:00:B0:05"] end it "detects the family" do - expect(@inet_interface_addresses[:family]).to eq('lladdr') + expect(@inet_interface_addresses[:family]).to eq("lladdr") end end end @@ -245,39 +245,39 @@ ARP_AN context "inet" do it "detects the route destinations" do - expect(@plugin['network']['interfaces']['en0'][:routes][0][:destination]).to eq("default") - expect(@plugin['network']['interfaces']['en0'][:routes][1][:destination]).to eq("172.29.128.0") + expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:destination]).to eq("default") + expect(@plugin["network"]["interfaces"]["en0"][:routes][1][:destination]).to eq("172.29.128.0") end it "detects the route family" do - expect(@plugin['network']['interfaces']['en0'][:routes][0][:family]).to eq("inet") + expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:family]).to eq("inet") end it "detects the route gateway" do - expect(@plugin['network']['interfaces']['en0'][:routes][0][:via]).to eq("172.29.128.13") + expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:via]).to eq("172.29.128.13") end it "detects the route flags" do - expect(@plugin['network']['interfaces']['en0'][:routes][0][:flags]).to eq("UG") + expect(@plugin["network"]["interfaces"]["en0"][:routes][0][:flags]).to eq("UG") end end context "inet6" do it "detects the route destinations" do - expect(@plugin['network']['interfaces']['en0'][:routes][4][:destination]).to eq("::1%1") + expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:destination]).to eq("::1%1") end it "detects the route family" do - expect(@plugin['network']['interfaces']['en0'][:routes][4][:family]).to eq("inet6") + expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:family]).to eq("inet6") end it "detects the route gateway" do - expect(@plugin['network']['interfaces']['en0'][:routes][4][:via]).to eq("::1%1") + expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:via]).to eq("::1%1") end it "detects the route flags" do - expect(@plugin['network']['interfaces']['en0'][:routes][4][:flags]).to eq("UH") + expect(@plugin["network"]["interfaces"]["en0"][:routes][4][:flags]).to eq("UH") end end end @@ -287,15 +287,15 @@ ARP_AN @plugin.run end it "supresses the hostname entries" do - expect(@plugin['network']['arp'][0][:remote_host]).to eq("?") + expect(@plugin["network"]["arp"][0][:remote_host]).to eq("?") end it "detects the remote ip entry" do - expect(@plugin['network']['arp'][0][:remote_ip]).to eq("172.29.131.16") + expect(@plugin["network"]["arp"][0][:remote_ip]).to eq("172.29.131.16") end it "detects the remote mac entry" do - expect(@plugin['network']['arp'][0][:remote_mac]).to eq("6e:87:70:0:40:3") + expect(@plugin["network"]["arp"][0][:remote_mac]).to eq("6e:87:70:0:40:3") end end @@ -304,7 +304,7 @@ ARP_AN @plugin.run end it "converts a netmask from hexadecimal form to decimal form" do - expect(@plugin.hex_to_dec_netmask('0xffff0000')).to eq("255.255.0.0") + expect(@plugin.hex_to_dec_netmask("0xffff0000")).to eq("255.255.0.0") end end end diff --git a/spec/unit/plugins/aix/os_spec.rb b/spec/unit/plugins/aix/os_spec.rb index 57f02a79..0d1e86e6 100644 --- a/spec/unit/plugins/aix/os_spec.rb +++ b/spec/unit/plugins/aix/os_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "AIX os plugin" do before(:each) do @@ -32,4 +32,3 @@ describe Ohai::System, "AIX os plugin" do expect(@plugin[:os_version]).to eql("6") end end - diff --git a/spec/unit/plugins/aix/platform_spec.rb b/spec/unit/plugins/aix/platform_spec.rb index 343f3ce0..318bc427 100644 --- a/spec/unit/plugins/aix/platform_spec.rb +++ b/spec/unit/plugins/aix/platform_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Aix plugin platform" do before(:each) do diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb index 503dec9f..071e561b 100644 --- a/spec/unit/plugins/aix/uptime_spec.rb +++ b/spec/unit/plugins/aix/uptime_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Aix plugin uptime" do diff --git a/spec/unit/plugins/aix/virtualization_spec.rb b/spec/unit/plugins/aix/virtualization_spec.rb index db0833b8..3d968e19 100644 --- a/spec/unit/plugins/aix/virtualization_spec.rb +++ b/spec/unit/plugins/aix/virtualization_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Ohai::System, "AIX virtualization plugin" do @@ -254,24 +254,24 @@ LSWPAR_L expect(plugin[:virtualization][:lpar_name]).to eq("l273pp027") end - context 'when WPARs exist on the LPAR' do + context "when WPARs exist on the LPAR" do before do plugin.run end let(:wpar1) do - plugin[:virtualization][:wpars]['applejack-541ba3'] + plugin[:virtualization][:wpars]["applejack-541ba3"] end let(:wpar2) do - plugin[:virtualization][:wpars]['fluttershy-5c969f'] + plugin[:virtualization][:wpars]["fluttershy-5c969f"] end - it 'detects all WPARs present (2)' do + it "detects all WPARs present (2)" do expect(plugin[:virtualization][:wpars].length).to eq(2) end - context 'when collecting WPAR info' do + context "when collecting WPAR info" do it 'finds the WPAR\'s hostname correctly' do expect(wpar1[:hostname]).to eq("applejack-pony-541ba3.ponyville.com") expect(wpar2[:hostname]).to eq("fluttershy-pony-5c969f.ponyville.com") @@ -282,20 +282,20 @@ LSWPAR_L expect(wpar2[:address]).to eq("192.168.0.18") end - it 'parses device exports properly' do - expect(wpar1['device exports']['/dev/nvram']['type']).to eq("pseudo") - expect(wpar1['device exports']['/dev/nvram']['status']).to eq("EXPORTED") + it "parses device exports properly" do + expect(wpar1["device exports"]["/dev/nvram"]["type"]).to eq("pseudo") + expect(wpar1["device exports"]["/dev/nvram"]["status"]).to eq("EXPORTED") end end end context 'when WPARs don\'t exist on the LPAR' do before do - allow(plugin).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, '', nil)) + allow(plugin).to receive(:shell_out).with("lswpar -L").and_return(mock_shell_out(0, "", nil)) plugin.run end - it 'detects all WPARs present (0)' do + it "detects all WPARs present (0)" do expect(plugin[:virtualization][:wpars]).to be_nil end end diff --git a/spec/unit/plugins/azure_spec.rb b/spec/unit/plugins/azure_spec.rb index e845df8c..5d1de59d 100644 --- a/spec/unit/plugins/azure_spec.rb +++ b/spec/unit/plugins/azure_spec.rb @@ -16,9 +16,8 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'open-uri' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "open-uri" describe Ohai::System, "plugin azure" do before(:each) do @@ -27,82 +26,82 @@ describe Ohai::System, "plugin azure" do describe "with azure hint file" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/azure.json").and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(true) allow(File).to receive(:read).with('C:\chef\ohai\hints/azure.json').and_return('{"public_ip":"137.135.46.202","vm_name":"test-vm","public_fqdn":"service.cloudapp.net","public_ssh_port":"22", "public_winrm_port":"5985"}') @plugin.run end - it 'should set the azure cloud attributes' do + it "should set the azure cloud attributes" do expect(@plugin[:azure]).not_to be_nil - expect(@plugin[:azure]['public_ip']).to eq("137.135.46.202") - expect(@plugin[:azure]['vm_name']).to eq("test-vm") - expect(@plugin[:azure]['public_fqdn']).to eq("service.cloudapp.net") - expect(@plugin[:azure]['public_ssh_port']).to eq("22") - expect(@plugin[:azure]['public_winrm_port']).to eq("5985") + expect(@plugin[:azure]["public_ip"]).to eq("137.135.46.202") + expect(@plugin[:azure]["vm_name"]).to eq("test-vm") + expect(@plugin[:azure]["public_fqdn"]).to eq("service.cloudapp.net") + expect(@plugin[:azure]["public_ssh_port"]).to eq("22") + expect(@plugin[:azure]["public_winrm_port"]).to eq("5985") end end describe "without azure hint file or agent or dhcp options" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/sbin/waagent').and_return(false) + allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) - allow(File).to receive(:exist?).with('/var/lib/dhcp/dhclient.eth0.leases').and_return(false) + allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(false) @plugin.run end - it 'should not behave like azure' do + it "should not behave like azure" do expect(@plugin[:azure]).to be_nil end end describe "with rackspace hint file no agent and no dhcp options" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') - allow(File).to receive(:exist?).with('/usr/sbin/waagent').and_return(false) - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("") + allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) - allow(File).to receive(:exist?).with('/var/lib/dhcp/dhclient.eth0.leases').and_return(false) + allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(false) @plugin.run end - it 'should not behave like azure' do + it "should not behave like azure" do expect(@plugin[:azure]).to be_nil end end describe "without azure hint file but with agent on linux" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/sbin/waagent').and_return(true) + allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(true) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) @plugin.run end - it 'should create empty azure mash' do + it "should create empty azure mash" do expect(@plugin[:azure]).to be_empty end end describe "without azure hint file but with agent on windows" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/sbin/waagent').and_return(false) + allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(true) @plugin.run end - it 'should create empty azure mash' do + it "should create empty azure mash" do puts "The dir exists?:" + "#{Dir.exist?('C:\WindowsAzure')}" expect(@plugin[:azure]).to be_empty end @@ -110,37 +109,37 @@ describe Ohai::System, "plugin azure" do describe "without azure hint or agent but with dhcp option" do before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/azure.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/azure.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/azure.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/sbin/waagent').and_return(false) + allow(File).to receive(:exist?).with("/usr/sbin/waagent").and_return(false) allow(Dir).to receive(:exist?).with('C:\WindowsAzure').and_return(false) - allow(File).to receive(:exist?).with('/var/lib/dhcp/dhclient.eth0.leases').and_return(true) + allow(File).to receive(:exist?).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(true) @double_file = double("/var/lib/dhcp/dhclient.eth0.leases") allow(@double_file).to receive(:each). - and_yield('lease {'). - and_yield(' interface "eth0";'). - and_yield(' fixed-address 10.1.0.5;'). - and_yield(' server-name "RD24BE05C6F140";'). - and_yield(' option subnet-mask 255.255.255.0;'). - and_yield(' option dhcp-lease-time 4294967295;'). - and_yield(' option routers 10.1.0.1;'). - and_yield(' option dhcp-message-type 5;'). - and_yield(' option dhcp-server-identifier 168.63.129.16;'). - and_yield(' option domain-name-servers 168.63.129.16;'). - and_yield(' option dhcp-renewal-time 4294967295;'). - and_yield(' option rfc3442-classless-static-routes 0,10,1,0,1,32,168,63,129,16,10,1,0,1;'). - and_yield(' option unknown-245 a8:3f:81:10;'). - and_yield(' option dhcp-rebinding-time 4294967295;'). - and_yield(' option domain-name "v4wvfurds4relghweduc4zqjmd.dx.internal.cloudapp.net";'). - and_yield(' renew 5 2152/03/10 09:03:39;'). - and_yield(' rebind 5 2152/03/10 09:03:39;'). - and_yield(' expire 5 2152/03/10 09:03:39;'). - and_yield('}') + and_yield("lease {"). + and_yield(' interface "eth0";'). + and_yield(" fixed-address 10.1.0.5;"). + and_yield(' server-name "RD24BE05C6F140";'). + and_yield(" option subnet-mask 255.255.255.0;"). + and_yield(" option dhcp-lease-time 4294967295;"). + and_yield(" option routers 10.1.0.1;"). + and_yield(" option dhcp-message-type 5;"). + and_yield(" option dhcp-server-identifier 168.63.129.16;"). + and_yield(" option domain-name-servers 168.63.129.16;"). + and_yield(" option dhcp-renewal-time 4294967295;"). + and_yield(" option rfc3442-classless-static-routes 0,10,1,0,1,32,168,63,129,16,10,1,0,1;"). + and_yield(" option unknown-245 a8:3f:81:10;"). + and_yield(" option dhcp-rebinding-time 4294967295;"). + and_yield(' option domain-name "v4wvfurds4relghweduc4zqjmd.dx.internal.cloudapp.net";'). + and_yield(" renew 5 2152/03/10 09:03:39;"). + and_yield(" rebind 5 2152/03/10 09:03:39;"). + and_yield(" expire 5 2152/03/10 09:03:39;"). + and_yield("}") allow(File).to receive(:open).with("/var/lib/dhcp/dhclient.eth0.leases").and_return(@double_file) @plugin.run end - it 'should create empty azure mash' do + it "should create empty azure mash" do puts "The dir exists?:" + "#{Dir.exist?('C:\WindowsAzure')}" expect(@plugin[:azure]).to be_empty end diff --git a/spec/unit/plugins/bsd/filesystem_spec.rb b/spec/unit/plugins/bsd/filesystem_spec.rb index e03db087..d337cf79 100644 --- a/spec/unit/plugins/bsd/filesystem_spec.rb +++ b/spec/unit/plugins/bsd/filesystem_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "BSD filesystem plugin" do let(:plugin) { get_plugin("bsd/filesystem") } diff --git a/spec/unit/plugins/bsd/virtualization_spec.rb b/spec/unit/plugins/bsd/virtualization_spec.rb index 0e01f16c..0df9136e 100644 --- a/spec/unit/plugins/bsd/virtualization_spec.rb +++ b/spec/unit/plugins/bsd/virtualization_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "BSD virtualization plugin" do before(:each) do @@ -24,7 +24,7 @@ describe Ohai::System, "BSD virtualization plugin" do allow(@plugin).to receive(:collect_os).and_return(:freebsd) allow(@plugin).to receive(:shell_out).with("sysctl -n security.jail.jailed").and_return(mock_shell_out(0, "0", "")) allow(@plugin).to receive(:shell_out).with("#{ Ohai.abs_path( "/sbin/kldstat" )}").and_return(mock_shell_out(0, "", "")) - allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, "","")) + allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, "", "")) allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, "", "")) end @@ -39,7 +39,7 @@ describe Ohai::System, "BSD virtualization plugin" do it "detects we are hosting jails" do # from http://www.freebsd.org/doc/handbook/jails-application.html - @jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www" + @jails = "JID IP Address Hostname Path\n 3 192.168.3.17 ns.example.org /home/j/ns\n 2 192.168.3.18 mail.example.org /home/j/mail\n 1 62.123.43.14 www.example.org /home/j/www" allow(@plugin).to receive(:shell_out).with("jls -n").and_return(mock_shell_out(0, @jails, "")) @plugin.run expect(@plugin[:virtualization][:system]).to eq("jail") @@ -86,7 +86,7 @@ OUT context "when on a QEMU guest" do it "detects we are a guest" do - [ 'Common KVM processor', 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', 'Common 32-bit KVM processor'].each do |kvm_string| + [ "Common KVM processor", 'QEMU Virtual CPU version (cpu64-rhel6) ("GenuineIntel" 686-class)', "Common 32-bit KVM processor"].each do |kvm_string| allow(@plugin).to receive(:shell_out).with("sysctl -n hw.model").and_return(mock_shell_out(0, kvm_string, "")) @plugin.run expect(@plugin[:virtualization][:system]).to eq("kvm") diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb index 96efd15d..78372132 100644 --- a/spec/unit/plugins/c_spec.rb +++ b/spec/unit/plugins/c_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'rbconfig' +require "rbconfig" -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) C_GCC = <. @@ -97,7 +97,7 @@ C_HPUX = < "1.2.3.4", "type" => "public"}, - {"ip_address" => "5.6.7.8", "type" => "private"}] - @plugin[:digital_ocean][:networks][:v6] = [{"ip_address" => "fe80::4240:95ff:fe47:6eee", "type" => "public"}, - {"ip_address" => "fdf8:f53b:82e4::53", "type" => "private"}] + @plugin[:digital_ocean][:networks][:v4] = [{ "ip_address" => "1.2.3.4", "type" => "public" }, + { "ip_address" => "5.6.7.8", "type" => "private" }] + @plugin[:digital_ocean][:networks][:v6] = [{ "ip_address" => "fe80::4240:95ff:fe47:6eee", "type" => "public" }, + { "ip_address" => "fdf8:f53b:82e4::53", "type" => "private" }] end before(:each) do @@ -230,29 +230,29 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public ips" do - expect(@plugin[:cloud][:public_ips]).to eq(@plugin[:digital_ocean][:networks][:v4].select{|ip| ip['type'] == 'public'} + - @plugin[:digital_ocean][:networks][:v6].select{|ip| ip['type'] == 'public'}) + expect(@plugin[:cloud][:public_ips]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "public" } + + @plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "public" }) end it "populates cloud private ips" do - expect(@plugin[:cloud][:private_ips]).to eq(@plugin[:digital_ocean][:networks][:v4].select{|ip| ip['type'] == 'private'} + - @plugin[:digital_ocean][:networks][:v6].select{|ip| ip['type'] == 'private'}) + expect(@plugin[:cloud][:private_ips]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "private" } + + @plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "private" }) end it "populates cloud public_ipv4" do - expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find{|ip| ip['type'] == 'public'}) + expect(@plugin[:cloud][:public_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "public" }) end it "populates cloud local_ipv4" do - expect(@plugin[:cloud][:local_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find{|ip| ip['type'] == 'private'}) + expect(@plugin[:cloud][:local_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "private" }) end it "populates cloud public_ipv6" do - expect(@plugin[:cloud][:public_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find{|ip| ip['type'] == 'public'}) + expect(@plugin[:cloud][:public_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "public" }) end it "populates cloud local_ipv6" do - expect(@plugin[:cloud][:local_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find{|ip| ip['type'] == 'private'}) + expect(@plugin[:cloud][:local_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "private" }) end it "populates cloud provider" do diff --git a/spec/unit/plugins/cloud_v2_spec.rb b/spec/unit/plugins/cloud_v2_spec.rb index d12ee9a7..e08e519d 100644 --- a/spec/unit/plugins/cloud_v2_spec.rb +++ b/spec/unit/plugins/cloud_v2_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'ipaddr' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "ipaddr" describe "CloudAttrs object" do before(:each) do @@ -24,17 +24,17 @@ describe "CloudAttrs object" do end let(:cloud_node) do - {"public_ipv4_addrs"=>["1.2.3.1"], - "local_ipv4_addrs"=>["1.2.4.1"], - "public_ipv6_addrs"=>["3ffe:505:2::1"], - "local_ipv6_addrs"=>["3ffe:506:2::1"], - "public_ipv4"=>"1.2.3.1", - "local_ipv4"=>"1.2.4.1", - "public_ipv6"=>"3ffe:505:2::1", - "local_ipv6"=>"3ffe:506:2::1", - "public_hostname"=>"myhost.somewhere.com", - "local_hostname"=>"my-localhost", - "provider"=>"my_awesome_cloud" + { "public_ipv4_addrs" => ["1.2.3.1"], + "local_ipv4_addrs" => ["1.2.4.1"], + "public_ipv6_addrs" => ["3ffe:505:2::1"], + "local_ipv6_addrs" => ["3ffe:506:2::1"], + "public_ipv4" => "1.2.3.1", + "local_ipv4" => "1.2.4.1", + "public_ipv6" => "3ffe:505:2::1", + "local_ipv6" => "3ffe:506:2::1", + "public_hostname" => "myhost.somewhere.com", + "local_hostname" => "my-localhost", + "provider" => "my_awesome_cloud", } end @@ -52,17 +52,17 @@ describe "CloudAttrs object" do it "throws exception with a bad ipv4 address" do @cloud_attr_obj = ::CloudAttrs.new() - expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error(RuntimeError) + expect { @cloud_attr_obj.add_ipv6_addr("somebogusstring", :public) }.to raise_error(RuntimeError) end it "throws exception with a bad ipv6 address" do @cloud_attr_obj = ::CloudAttrs.new() - expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error(RuntimeError) + expect { @cloud_attr_obj.add_ipv6_addr("FEED:B0B:DEAD:BEEF", :public) }.to raise_error(RuntimeError) end it "throws exception with ipv6 address passed to ipv4" do @cloud_attr_obj = ::CloudAttrs.new() - expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error(RuntimeError) + expect { @cloud_attr_obj.add_ipv4_addr("3ffe:506:2::1", :public) }.to raise_error(RuntimeError) end it "throws exception with ipv4 address passed to ipv6" do @@ -70,7 +70,6 @@ describe "CloudAttrs object" do expect { @cloud_attr_obj.add_ipv6_addr("1.2.3.4", :public) }.to raise_error(RuntimeError) end - end describe Ohai::System, "plugin cloud" do @@ -98,15 +97,15 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public ip" do - @plugin[:ec2]['public_ipv4'] = "174.129.150.8" + @plugin[:ec2]["public_ipv4"] = "174.129.150.8" @plugin.run - expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]['public_ipv4']) + expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:ec2]["public_ipv4"]) end it "populates cloud private ip" do - @plugin[:ec2]['local_ipv4'] = "10.252.42.149" + @plugin[:ec2]["local_ipv4"] = "10.252.42.149" @plugin.run - expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]['local_ipv4']) + expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:ec2]["local_ipv4"]) end it "populates cloud provider" do @@ -119,13 +118,13 @@ describe Ohai::System, "plugin cloud" do describe "with a public IP" do before do @plugin[:gce] = Mash.new() - @plugin[:gce]['instance'] = Mash.new() - @plugin[:gce]['instance']['networkInterfaces'] = [ + @plugin[:gce]["instance"] = Mash.new() + @plugin[:gce]["instance"]["networkInterfaces"] = [ { - "accessConfigs" => [ {"externalIp" => "8.35.198.173", "type"=>"ONE_TO_ONE_NAT"} ], + "accessConfigs" => [ { "externalIp" => "8.35.198.173", "type" => "ONE_TO_ONE_NAT" } ], "ip" => "10.240.0.102", - "network"=> "projects/foo/networks/default" - } + "network" => "projects/foo/networks/default", + }, ] end @@ -148,13 +147,13 @@ describe Ohai::System, "plugin cloud" do describe "with no public IP" do before do @plugin[:gce] = Mash.new() - @plugin[:gce]['instance'] = Mash.new() - @plugin[:gce]['instance']['networkInterfaces'] = [ + @plugin[:gce]["instance"] = Mash.new() + @plugin[:gce]["instance"]["networkInterfaces"] = [ { - "accessConfigs" => [ {"externalIp" => "", "type" => "ONE_TO_ONE_NAT"} ], + "accessConfigs" => [ { "externalIp" => "", "type" => "ONE_TO_ONE_NAT" } ], "ip" => "10.240.0.102", - "network" => "projects/foo/networks/default" - } + "network" => "projects/foo/networks/default", + }, ] end @@ -228,19 +227,19 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public ip" do - @plugin[:linode]['public_ip'] = "174.129.150.8" + @plugin[:linode]["public_ip"] = "174.129.150.8" @plugin.run expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:linode][:public_ip]) end it "populates cloud private ip" do - @plugin[:linode]['private_ip'] = "10.252.42.149" + @plugin[:linode]["private_ip"] = "10.252.42.149" @plugin.run expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:linode][:private_ip]) end it "populates first cloud public ip" do - @plugin[:linode]['public_ip'] = "174.129.150.8" + @plugin[:linode]["public_ip"] = "174.129.150.8" @plugin.run expect(@plugin[:cloud_v2][:public_ipv4_addrs].first).to eq(@plugin[:linode][:public_ip]) end @@ -257,15 +256,15 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public ip" do - @plugin[:eucalyptus]['public_ipv4'] = "174.129.150.8" + @plugin[:eucalyptus]["public_ipv4"] = "174.129.150.8" @plugin.run - expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]['public_ipv4']) + expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["public_ipv4"]) end it "populates cloud private ip" do - @plugin[:eucalyptus]['local_ipv4'] = "10.252.42.149" + @plugin[:eucalyptus]["local_ipv4"] = "10.252.42.149" @plugin.run - expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]['local_ipv4']) + expect(@plugin[:cloud_v2][:local_ipv4_addrs][0]).to eq(@plugin[:eucalyptus]["local_ipv4"]) end it "populates cloud provider" do @@ -280,37 +279,37 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public ip" do - @plugin[:azure]['public_ip'] = "174.129.150.8" + @plugin[:azure]["public_ip"] = "174.129.150.8" @plugin.run - expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:azure]['public_ip']) + expect(@plugin[:cloud_v2][:public_ipv4_addrs][0]).to eq(@plugin[:azure]["public_ip"]) end it "doesn't populates cloud vm_name" do - @plugin[:azure]['vm_name'] = "linux-vm" + @plugin[:azure]["vm_name"] = "linux-vm" @plugin.run - expect(@plugin[:cloud_v2][:vm_name]).not_to eq(@plugin[:azure]['vm_name']) + expect(@plugin[:cloud_v2][:vm_name]).not_to eq(@plugin[:azure]["vm_name"]) end it "populates cloud public_hostname" do - @plugin[:azure]['public_fqdn'] = "linux-vm-svc.cloudapp.net" + @plugin[:azure]["public_fqdn"] = "linux-vm-svc.cloudapp.net" @plugin.run - expect(@plugin[:cloud_v2][:public_hostname]).to eq(@plugin[:azure]['public_fqdn']) + expect(@plugin[:cloud_v2][:public_hostname]).to eq(@plugin[:azure]["public_fqdn"]) end it "doesn't populate cloud public_ssh_port" do - @plugin[:azure]['public_ssh_port'] = "22" + @plugin[:azure]["public_ssh_port"] = "22" @plugin.run expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil end it "should not populate cloud public_ssh_port when winrm is used" do - @plugin[:azure]['public_winrm_port'] = "5985" + @plugin[:azure]["public_winrm_port"] = "5985" @plugin.run expect(@plugin[:cloud_v2][:public_ssh_port]).to be_nil end it "populates cloud public_winrm_port" do - @plugin[:azure]['public_winrm_port'] = "5985" + @plugin[:azure]["public_winrm_port"] = "5985" @plugin.run expect(@plugin[:cloud_v2][:public_winrm_port]).to be_nil end @@ -326,10 +325,10 @@ describe Ohai::System, "plugin cloud" do @plugin[:digital_ocean] = Mash.new @plugin[:digital_ocean][:name] = "public.example.com" @plugin[:digital_ocean][:networks] = Mash.new - @plugin[:digital_ocean][:networks][:v4] = [{"ip_address" => "1.2.3.4", "type" => "public"}, - {"ip_address" => "5.6.7.8", "type" => "private"}] - @plugin[:digital_ocean][:networks][:v6] = [{"ip_address" => "fe80::4240:95ff:fe47:6eee", "type" => "public"}, - {"ip_address" => "fdf8:f53b:82e4::53", "type" => "private"}] + @plugin[:digital_ocean][:networks][:v4] = [{ "ip_address" => "1.2.3.4", "type" => "public" }, + { "ip_address" => "5.6.7.8", "type" => "private" }] + @plugin[:digital_ocean][:networks][:v6] = [{ "ip_address" => "fe80::4240:95ff:fe47:6eee", "type" => "public" }, + { "ip_address" => "fdf8:f53b:82e4::53", "type" => "private" }] end before(:each) do @@ -345,41 +344,41 @@ describe Ohai::System, "plugin cloud" do end it "populates cloud public_ipv4_addrs" do - expect(@plugin[:cloud_v2][:public_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select{|ip| ip['type'] == 'public'} - .map{|ip| ip['ip_address']}) - + expect(@plugin[:cloud_v2][:public_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "public" } + .map { |ip| ip["ip_address"] }) + end it "populates cloud local_ipv4_addrs" do - expect(@plugin[:cloud_v2][:local_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select{|ip| ip['type'] == 'private'} - .map{|ip| ip['ip_address']}) - + expect(@plugin[:cloud_v2][:local_ipv4_addrs]).to eq(@plugin[:digital_ocean][:networks][:v4].select { |ip| ip["type"] == "private" } + .map { |ip| ip["ip_address"] }) + end it "populates cloud public_ipv4" do - expect(@plugin[:cloud_v2][:public_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find{|ip| ip['type'] == 'public'}['ip_address']) + expect(@plugin[:cloud_v2][:public_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "public" }["ip_address"]) end it "populates cloud local_ipv4" do - expect(@plugin[:cloud_v2][:local_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find{|ip| ip['type'] == 'private'}['ip_address']) + expect(@plugin[:cloud_v2][:local_ipv4]).to eq(@plugin[:digital_ocean][:networks][:v4].find { |ip| ip["type"] == "private" }["ip_address"]) end it "populates cloud public_ipv6_addrs" do - expect(@plugin[:cloud_v2][:public_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select{|ip| ip['type'] == 'public'} - .map{|ip| ip['ip_address']}) + expect(@plugin[:cloud_v2][:public_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "public" } + .map { |ip| ip["ip_address"] }) end it "populates cloud local_ipv6_addrs" do - expect(@plugin[:cloud_v2][:local_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select{|ip| ip['type'] == 'private'} - .map{|ip| ip['ip_address']}) + expect(@plugin[:cloud_v2][:local_ipv6_addrs]).to eq(@plugin[:digital_ocean][:networks][:v6].select { |ip| ip["type"] == "private" } + .map { |ip| ip["ip_address"] }) end it "populates cloud public_ipv6" do - expect(@plugin[:cloud_v2][:public_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find{|ip| ip['type'] == 'public'}['ip_address']) + expect(@plugin[:cloud_v2][:public_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "public" }["ip_address"]) end it "populates cloud local_ipv6" do - expect(@plugin[:cloud_v2][:local_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find{|ip| ip['type'] == 'private'}['ip_address']) + expect(@plugin[:cloud_v2][:local_ipv6]).to eq(@plugin[:digital_ocean][:networks][:v6].find { |ip| ip["type"] == "private" }["ip_address"]) end it "populates cloud provider" do diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb index 4cd1d92d..d6930c80 100644 --- a/spec/unit/plugins/darwin/cpu_spec.rb +++ b/spec/unit/plugins/darwin/cpu_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin cpu plugin" do before(:each) do diff --git a/spec/unit/plugins/darwin/filesystem2_spec.rb b/spec/unit/plugins/darwin/filesystem2_spec.rb index c34aa8bd..2a652593 100644 --- a/spec/unit/plugins/darwin/filesystem2_spec.rb +++ b/spec/unit/plugins/darwin/filesystem2_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "darwin filesystem2 plugin" do let (:plugin) { get_plugin("darwin/filesystem2") } @@ -59,7 +59,7 @@ DF expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:device]).to eq("/dev/disk0s2") end - + it "should set inode info to value from df -i" do plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:total_inodes]).to eq("61069440") @@ -90,7 +90,7 @@ MOUNT plugin.run expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount]).to eq("/") expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:fs_type]).to eq("hfs") - expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq([ "local", "journaled" ]) + expect(plugin[:filesystem2]["by_pair"]["/dev/disk0s2,/"][:mount_options]).to eq(%w{local journaled}) end end @@ -111,7 +111,7 @@ DF it "should provide a devices view with all mountpoints" do plugin.run - expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(['/', '/another/mountpoint']) + expect(plugin[:filesystem2]["by_device"]["/dev/disk0s2"][:mounts]).to eq(["/", "/another/mountpoint"]) end end @@ -133,7 +133,7 @@ DF it "should provide a mounts view with all devices" do plugin.run - expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/disk0s3', '/dev/disk0s4']) + expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/disk0s3", "/dev/disk0s4"]) end end end diff --git a/spec/unit/plugins/darwin/filesystem_spec.rb b/spec/unit/plugins/darwin/filesystem_spec.rb index 4b798973..b703bce9 100644 --- a/spec/unit/plugins/darwin/filesystem_spec.rb +++ b/spec/unit/plugins/darwin/filesystem_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "darwin filesystem plugin" do let (:plugin) { get_plugin("darwin/filesystem") } @@ -58,7 +58,7 @@ DF plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") end - + it "should set inode info to value from df -i" do plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:total_inodes]).to eq("61069440") @@ -89,7 +89,7 @@ MOUNT plugin.run expect(plugin[:filesystem]["/dev/disk0s2"][:mount]).to eq("/") expect(plugin[:filesystem]["/dev/disk0s2"][:fs_type]).to eq("hfs") - expect(plugin[:filesystem]["/dev/disk0s2"][:mount_options]).to eq([ "local", "journaled" ]) + expect(plugin[:filesystem]["/dev/disk0s2"][:mount_options]).to eq(%w{local journaled}) end end end diff --git a/spec/unit/plugins/darwin/hostname_spec.rb b/spec/unit/plugins/darwin/hostname_spec.rb index eb5f5437..b95c8f8a 100644 --- a/spec/unit/plugins/darwin/hostname_spec.rb +++ b/spec/unit/plugins/darwin/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin hostname plugin" do before(:each) do @@ -42,5 +41,3 @@ describe Ohai::System, "Darwin hostname plugin" do expect(@plugin[:domain]).to eq("bethell") end end - - diff --git a/spec/unit/plugins/darwin/kernel_spec.rb b/spec/unit/plugins/darwin/kernel_spec.rb index b364849b..092beba0 100644 --- a/spec/unit/plugins/darwin/kernel_spec.rb +++ b/spec/unit/plugins/darwin/kernel_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin kernel plugin" do before(:each) do @@ -35,12 +34,9 @@ describe Ohai::System, "Darwin kernel plugin" do EOF modules = { - "com.apple.kec.corecrypto"=> - {"version"=>"1.0", "size"=>266240, "index"=>"8", "refcount"=>"0"}, - "com.apple.iokit.IOACPIFamily"=> - {"version"=>"1.4", "size"=>36864, "index"=>"9", "refcount"=>"22"}, - "com.apple.iokit.IOPCIFamily"=> - {"version"=>"2.8", "size"=>167936, "index"=>"10", "refcount"=>"30"}} + "com.apple.kec.corecrypto" => { "version" => "1.0", "size" => 266240, "index" => "8", "refcount" => "0" }, + "com.apple.iokit.IOACPIFamily" => { "version" => "1.4", "size" => 36864, "index" => "9", "refcount" => "22" }, + "com.apple.iokit.IOPCIFamily" => { "version" => "2.8", "size" => 167936, "index" => "10", "refcount" => "30" } } @plugin.run expect(@plugin[:kernel][:modules]).to eql(modules) @@ -50,14 +46,14 @@ EOF allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "0", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) @plugin.run - expect(@plugin[:kernel][:machine]).not_to eq('x86_64') + expect(@plugin[:kernel][:machine]).not_to eq("x86_64") end it "should set kernel_machine to x86_64" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.optional.x86_64").and_return(mock_shell_out(0, "1", "")) allow(@plugin).to receive(:shell_out).with("kextstat -k -l").and_return(mock_shell_out(0, "", "")) @plugin.run - expect(@plugin[:kernel][:machine]).to eq('x86_64') + expect(@plugin[:kernel][:machine]).to eq("x86_64") end it "should set the kernel_os to the kernel_name value" do diff --git a/spec/unit/plugins/darwin/memory_spec.rb b/spec/unit/plugins/darwin/memory_spec.rb index 5db76cb0..b089fb87 100644 --- a/spec/unit/plugins/darwin/memory_spec.rb +++ b/spec/unit/plugins/darwin/memory_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin Memory Plugin" do before(:each) do @@ -47,18 +47,18 @@ Object cache: 12 hits of 139872 lookups (0% hit rate) end it "should set memory[:total] to 16384MB" do - expect(@plugin[:memory][:total]).to eq('16384MB') + expect(@plugin[:memory][:total]).to eq("16384MB") end it "should set memory[:active] to 5140MB" do - expect(@plugin[:memory][:active]).to eq('5140MB') + expect(@plugin[:memory][:active]).to eq("5140MB") end it "should set memory[:inactive] to 738MB" do - expect(@plugin[:memory][:inactive]).to eq('738MB') + expect(@plugin[:memory][:inactive]).to eq("738MB") end it "should set memory[:free] to 10504MB" do - expect(@plugin[:memory][:free]).to eq('10504MB') + expect(@plugin[:memory][:free]).to eq("10504MB") end end diff --git a/spec/unit/plugins/darwin/network_spec.rb b/spec/unit/plugins/darwin/network_spec.rb index 474104ef..7b549dea 100644 --- a/spec/unit/plugins/darwin/network_spec.rb +++ b/spec/unit/plugins/darwin/network_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin Network Plugin" do before(:each) do @@ -439,412 +439,411 @@ net.smb.fs.tcprcvbuf: 261120 end it "completes the run" do - expect(@plugin['network']).not_to be_nil + expect(@plugin["network"]).not_to be_nil end it "detects the interfaces" do - expect(@plugin['network']['interfaces'].keys.sort).to eq(["en0", "en1", "fw0", "gif0", "lo0", "p2p0", "stf0", "utun0"]) + expect(@plugin["network"]["interfaces"].keys.sort).to eq(%w{en0 en1 fw0 gif0 lo0 p2p0 stf0 utun0}) end it "detects the ipv4 addresses of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('10.20.10.144') - expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['netmask']).to eq('255.255.255.0') - expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['broadcast']).to eq('10.20.10.255') - expect(@plugin['network']['interfaces']['en1']['addresses']['10.20.10.144']['family']).to eq('inet') + expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("10.20.10.144") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["netmask"]).to eq("255.255.255.0") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["broadcast"]).to eq("10.20.10.255") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["10.20.10.144"]["family"]).to eq("inet") end it "detects the ipv6 addresses of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('fe80::ba8d:12ff:fe3a:32de') - expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['scope']).to eq('Link') - expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['prefixlen']).to eq('64') - expect(@plugin['network']['interfaces']['en1']['addresses']['fe80::ba8d:12ff:fe3a:32de']['family']).to eq('inet6') - - expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('2001:44b8:4186:1100:ba8d:12ff:fe3a:32de') - expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['scope']).to eq('Global') - expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['prefixlen']).to eq('64') - expect(@plugin['network']['interfaces']['en1']['addresses']['2001:44b8:4186:1100:ba8d:12ff:fe3a:32de']['family']).to eq('inet6') + expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("fe80::ba8d:12ff:fe3a:32de") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["scope"]).to eq("Link") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["fe80::ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6") + + expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("2001:44b8:4186:1100:ba8d:12ff:fe3a:32de") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["scope"]).to eq("Global") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["prefixlen"]).to eq("64") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["2001:44b8:4186:1100:ba8d:12ff:fe3a:32de"]["family"]).to eq("inet6") end it "detects the mac addresses of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['addresses'].keys).to include('b8:8d:12:3a:32:de') - expect(@plugin['network']['interfaces']['en1']['addresses']['b8:8d:12:3a:32:de']['family']).to eq('lladdr') + expect(@plugin["network"]["interfaces"]["en1"]["addresses"].keys).to include("b8:8d:12:3a:32:de") + expect(@plugin["network"]["interfaces"]["en1"]["addresses"]["b8:8d:12:3a:32:de"]["family"]).to eq("lladdr") end it "detects the encapsulation type of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['encapsulation']).to eq('Ethernet') + expect(@plugin["network"]["interfaces"]["en1"]["encapsulation"]).to eq("Ethernet") end it "detects the flags of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['flags'].sort).to eq(["BROADCAST", "MULTICAST", "RUNNING", "SIMPLEX", "SMART", "UP"]) + expect(@plugin["network"]["interfaces"]["en1"]["flags"].sort).to eq(%w{BROADCAST MULTICAST RUNNING SIMPLEX SMART UP}) end - it "detects the mtu of the ethernet interface" do - expect(@plugin['network']['interfaces']['en1']['mtu']).to eq("1500") + expect(@plugin["network"]["interfaces"]["en1"]["mtu"]).to eq("1500") end it "detects the ipv4 addresses of the loopback interface" do - expect(@plugin['network']['interfaces']['lo0']['addresses'].keys).to include('127.0.0.1') - expect(@plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['netmask']).to eq('255.0.0.0') - expect(@plugin['network']['interfaces']['lo0']['addresses']['127.0.0.1']['family']).to eq('inet') + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("127.0.0.1") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["netmask"]).to eq("255.0.0.0") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["127.0.0.1"]["family"]).to eq("inet") end it "detects the ipv6 addresses of the loopback interface" do - expect(@plugin['network']['interfaces']['lo0']['addresses'].keys).to include('::1') - expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['scope']).to eq('Node') - expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['prefixlen']).to eq('128') - expect(@plugin['network']['interfaces']['lo0']['addresses']['::1']['family']).to eq('inet6') + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"].keys).to include("::1") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["scope"]).to eq("Node") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["prefixlen"]).to eq("128") + expect(@plugin["network"]["interfaces"]["lo0"]["addresses"]["::1"]["family"]).to eq("inet6") end it "detects the encapsulation type of the loopback interface" do - expect(@plugin['network']['interfaces']['lo0']['encapsulation']).to eq('Loopback') + expect(@plugin["network"]["interfaces"]["lo0"]["encapsulation"]).to eq("Loopback") end it "detects the flags of the ethernet interface" do - expect(@plugin['network']['interfaces']['lo0']['flags'].sort).to eq(["LOOPBACK", "MULTICAST", "RUNNING", "UP"]) + expect(@plugin["network"]["interfaces"]["lo0"]["flags"].sort).to eq(%w{LOOPBACK MULTICAST RUNNING UP}) end it "detects the mtu of the loopback interface" do - expect(@plugin['network']['interfaces']['lo0']['mtu']).to eq("16384") + expect(@plugin["network"]["interfaces"]["lo0"]["mtu"]).to eq("16384") end it "detects the arp entries" do - expect(@plugin['network']['interfaces']['en1']['arp']['10.20.10.1']).to eq('0:4:ed:de:41:bf') + expect(@plugin["network"]["interfaces"]["en1"]["arp"]["10.20.10.1"]).to eq("0:4:ed:de:41:bf") end it "detects the ethernet counters" do - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['bytes']).to eq("18228234970") - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['packets']).to eq("14314573") - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['collisions']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['errors']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['carrier']).to eq(0) - expect(@plugin['counters']['network']['interfaces']['en1']['tx']['drop']).to eq(0) - - expect(@plugin['counters']['network']['interfaces']['en1']['rx']['bytes']).to eq("2530556736") - expect(@plugin['counters']['network']['interfaces']['en1']['rx']['packets']).to eq("5921903") - expect(@plugin['counters']['network']['interfaces']['en1']['rx']['errors']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['en1']['rx']['overrun']).to eq(0) - expect(@plugin['counters']['network']['interfaces']['en1']['rx']['drop']).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["bytes"]).to eq("18228234970") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["packets"]).to eq("14314573") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["collisions"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["carrier"]).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["tx"]["drop"]).to eq(0) + + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["bytes"]).to eq("2530556736") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["packets"]).to eq("5921903") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["overrun"]).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["en1"]["rx"]["drop"]).to eq(0) end it "detects the loopback counters" do - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['bytes']).to eq("25774844") - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['packets']).to eq("174982") - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['collisions']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['errors']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['carrier']).to eq(0) - expect(@plugin['counters']['network']['interfaces']['lo0']['tx']['drop']).to eq(0) - - expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['bytes']).to eq("25774844") - expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['packets']).to eq("174982") - expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['errors']).to eq("0") - expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['overrun']).to eq(0) - expect(@plugin['counters']['network']['interfaces']['lo0']['rx']['drop']).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["bytes"]).to eq("25774844") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["packets"]).to eq("174982") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["collisions"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["carrier"]).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["tx"]["drop"]).to eq(0) + + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["bytes"]).to eq("25774844") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["packets"]).to eq("174982") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["errors"]).to eq("0") + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["overrun"]).to eq(0) + expect(@plugin["counters"]["network"]["interfaces"]["lo0"]["rx"]["drop"]).to eq(0) end it "finds the default interface by asking which iface has the default route" do - expect(@plugin['network'][:default_interface]).to eq('en1') + expect(@plugin["network"][:default_interface]).to eq("en1") end it "finds the default interface by asking which iface has the default route" do - expect(@plugin['network'][:default_gateway]).to eq('10.20.10.1') + expect(@plugin["network"][:default_gateway]).to eq("10.20.10.1") end it "should detect network settings" do - expect(@plugin['network']['settings']['net.local.stream.sendspace']).to eq('8192') - expect(@plugin["network"]["settings"]['net.local.stream.recvspace']).to eq('8192') - expect(@plugin["network"]["settings"]['net.local.stream.tracemdns']).to eq('0') - expect(@plugin["network"]["settings"]['net.local.dgram.maxdgram']).to eq('2048') - expect(@plugin["network"]["settings"]['net.local.dgram.recvspace']).to eq('4096') - expect(@plugin["network"]["settings"]['net.local.inflight']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.lowfirst']).to eq('1023') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.lowlast']).to eq('600') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.first']).to eq('49152') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.last']).to eq('65535') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.hifirst']).to eq('49152') - expect(@plugin["network"]["settings"]['net.inet.ip.portrange.hilast']).to eq('65535') - expect(@plugin["network"]["settings"]['net.inet.ip.forwarding']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.redirect']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.ttl']).to eq('64') - expect(@plugin["network"]["settings"]['net.inet.ip.rtexpire']).to eq('12') - expect(@plugin["network"]["settings"]['net.inet.ip.rtminexpire']).to eq('10') - expect(@plugin["network"]["settings"]['net.inet.ip.rtmaxcache']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet.ip.sourceroute']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.intr_queue_maxlen']).to eq('50') - expect(@plugin["network"]["settings"]['net.inet.ip.intr_queue_drops']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.accept_sourceroute']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.keepfaith']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.gifttl']).to eq('30') - expect(@plugin["network"]["settings"]['net.inet.ip.subnets_are_local']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.mcast.maxgrpsrc']).to eq('512') - expect(@plugin["network"]["settings"]['net.inet.ip.mcast.maxsocksrc']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet.ip.mcast.loop']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.check_route_selfref']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.use_route_genid']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.hash_size']).to eq('64') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.curr_time']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.ready_heap']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.extract_heap']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.searches']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.search_steps']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.expire']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.max_chain_len']).to eq('16') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_lookup_depth']).to eq('256') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_avg_pkt_size']).to eq('512') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.red_max_pkt_size']).to eq('1500') - expect(@plugin["network"]["settings"]['net.inet.ip.dummynet.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.enable']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.autoinc_step']).to eq('100') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.one_pass']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.verbose']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.verbose_limit']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_buckets']).to eq('256') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.curr_dyn_buckets']).to eq('256') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_count']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_max']).to eq('4096') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.static_count']).to eq('2') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_ack_lifetime']).to eq('300') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_syn_lifetime']).to eq('20') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_fin_lifetime']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_rst_lifetime']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_udp_lifetime']).to eq('10') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_short_lifetime']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet.ip.fw.dyn_keepalive']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.maxfragpackets']).to eq('1536') - expect(@plugin["network"]["settings"]['net.inet.ip.maxfragsperpacket']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet.ip.maxfrags']).to eq('3072') - expect(@plugin["network"]["settings"]['net.inet.ip.scopedroute']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.check_interface']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.linklocal.in.allowbadttl']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.random_id']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ip.maxchainsent']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ip.select_srcif_debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.icmp.maskrepl']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.icmp.icmplim']).to eq('250') - expect(@plugin["network"]["settings"]['net.inet.icmp.timestamp']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.icmp.drop_redirect']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.icmp.log_redirect']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.icmp.bmcastecho']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.recvifkludge']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.sendra']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.sendlocal']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.v1enable']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.v2enable']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.igmp.legacysupp']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.igmp.default_version']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet.igmp.gsrdelay']).to eq('10') - expect(@plugin["network"]["settings"]['net.inet.igmp.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.rfc1323']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.rfc1644']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.mssdflt']).to eq('512') - expect(@plugin["network"]["settings"]['net.inet.tcp.keepidle']).to eq('7200000') - expect(@plugin["network"]["settings"]['net.inet.tcp.keepintvl']).to eq('75000') - expect(@plugin["network"]["settings"]['net.inet.tcp.sendspace']).to eq('65536') - expect(@plugin["network"]["settings"]['net.inet.tcp.recvspace']).to eq('65536') - expect(@plugin["network"]["settings"]['net.inet.tcp.keepinit']).to eq('75000') - expect(@plugin["network"]["settings"]['net.inet.tcp.v6mssdflt']).to eq('1024') - expect(@plugin["network"]["settings"]['net.inet.tcp.log_in_vain']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.blackhole']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.delayed_ack']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_lq_overflow']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.recvbg']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.drop_synfin']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.reass.maxsegments']).to eq('3072') - expect(@plugin["network"]["settings"]['net.inet.tcp.reass.cursegments']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.reass.overflows']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.slowlink_wsize']).to eq('8192') - expect(@plugin["network"]["settings"]['net.inet.tcp.maxseg_unacked']).to eq('8') - expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3465']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3465_lim2']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.rtt_samples_per_slot']).to eq('20') - expect(@plugin["network"]["settings"]['net.inet.tcp.recv_allowed_iaj']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet.tcp.acc_iaj_high_thresh']).to eq('100') - expect(@plugin["network"]["settings"]['net.inet.tcp.rexmt_thresh']).to eq('2') - expect(@plugin["network"]["settings"]['net.inet.tcp.path_mtu_discovery']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.slowstart_flightsize']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.local_slowstart_flightsize']).to eq('8') - expect(@plugin["network"]["settings"]['net.inet.tcp.tso']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.ecn_initiate_out']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.ecn_negotiate_in']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.packetchain']).to eq('50') - expect(@plugin["network"]["settings"]['net.inet.tcp.socket_unlocked_on_output']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.rfc3390']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.min_iaj_win']).to eq('4') - expect(@plugin["network"]["settings"]['net.inet.tcp.acc_iaj_react_limit']).to eq('200') - expect(@plugin["network"]["settings"]['net.inet.tcp.sack']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.sack_maxholes']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet.tcp.sack_globalmaxholes']).to eq('65536') - expect(@plugin["network"]["settings"]['net.inet.tcp.sack_globalholes']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.minmss']).to eq('216') - expect(@plugin["network"]["settings"]['net.inet.tcp.minmssoverload']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.do_tcpdrain']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.pcbcount']).to eq('86') - expect(@plugin["network"]["settings"]['net.inet.tcp.icmp_may_rst']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.strict_rfc1948']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.isn_reseed_interval']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.background_io_enabled']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.rtt_min']).to eq('100') - expect(@plugin["network"]["settings"]['net.inet.tcp.rexmt_slop']).to eq('200') - expect(@plugin["network"]["settings"]['net.inet.tcp.randomize_ports']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.newreno_sockets']).to eq('81') - expect(@plugin["network"]["settings"]['net.inet.tcp.background_sockets']).to eq('-1') - expect(@plugin["network"]["settings"]['net.inet.tcp.tcbhashsize']).to eq('4096') - expect(@plugin["network"]["settings"]['net.inet.tcp.background_io_trigger']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet.tcp.msl']).to eq('15000') - expect(@plugin["network"]["settings"]['net.inet.tcp.max_persist_timeout']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.always_keepalive']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.tcp.timer_fastmode_idlemax']).to eq('20') - expect(@plugin["network"]["settings"]['net.inet.tcp.broken_peer_syn_rxmit_thres']).to eq('7') - expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_timer_advanced']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet.tcp.tcp_resched_timerlist']).to eq('12209') - expect(@plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_detection']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.pmtud_blackhole_mss']).to eq('1200') - expect(@plugin["network"]["settings"]['net.inet.tcp.timer_fastquantum']).to eq('100') - expect(@plugin["network"]["settings"]['net.inet.tcp.timer_slowquantum']).to eq('500') - expect(@plugin["network"]["settings"]['net.inet.tcp.win_scale_factor']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet.tcp.sockthreshold']).to eq('64') - expect(@plugin["network"]["settings"]['net.inet.tcp.bg_target_qdelay']).to eq('100') - expect(@plugin["network"]["settings"]['net.inet.tcp.bg_allowed_increase']).to eq('2') - expect(@plugin["network"]["settings"]['net.inet.tcp.bg_tether_shift']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.tcp.bg_ss_fltsz']).to eq('2') - expect(@plugin["network"]["settings"]['net.inet.udp.checksum']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.udp.maxdgram']).to eq('9216') - expect(@plugin["network"]["settings"]['net.inet.udp.recvspace']).to eq('42080') - expect(@plugin["network"]["settings"]['net.inet.udp.log_in_vain']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.udp.blackhole']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.udp.pcbcount']).to eq('72') - expect(@plugin["network"]["settings"]['net.inet.udp.randomize_ports']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.def_policy']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_trans_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_net_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_trans_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_net_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_cleartos']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.ah_offsetmask']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ipsec.dfbit']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ipsec.ecn']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ipsec.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_randpad']).to eq('-1') - expect(@plugin["network"]["settings"]['net.inet.ipsec.bypass']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet.ipsec.esp_port']).to eq('4500') - expect(@plugin["network"]["settings"]['net.inet.raw.maxdgram']).to eq('8192') - expect(@plugin["network"]["settings"]['net.inet.raw.recvspace']).to eq('8192') - expect(@plugin["network"]["settings"]['net.link.generic.system.ifcount']).to eq('10') - expect(@plugin["network"]["settings"]['net.link.generic.system.dlil_verbose']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.generic.system.multi_threaded_input']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.generic.system.dlil_input_sanity_check']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.ether.inet.prune_intvl']).to eq('300') - expect(@plugin["network"]["settings"]['net.link.ether.inet.max_age']).to eq('1200') - expect(@plugin["network"]["settings"]['net.link.ether.inet.host_down_time']).to eq('20') - expect(@plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_tx']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.ether.inet.apple_hwcksum_rx']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.ether.inet.arp_llreach_base']).to eq('30') - expect(@plugin["network"]["settings"]['net.link.ether.inet.maxtries']).to eq('5') - expect(@plugin["network"]["settings"]['net.link.ether.inet.useloopback']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.ether.inet.proxyall']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.ether.inet.sendllconflict']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.ether.inet.log_arp_warnings']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.ether.inet.keep_announcements']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.ether.inet.send_conflicting_probes']).to eq('1') - expect(@plugin["network"]["settings"]['net.link.bridge.log_stp']).to eq('0') - expect(@plugin["network"]["settings"]['net.link.bridge.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.key.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.key.spi_trycnt']).to eq('1000') - expect(@plugin["network"]["settings"]['net.key.spi_minval']).to eq('256') - expect(@plugin["network"]["settings"]['net.key.spi_maxval']).to eq('268435455') - expect(@plugin["network"]["settings"]['net.key.int_random']).to eq('60') - expect(@plugin["network"]["settings"]['net.key.larval_lifetime']).to eq('30') - expect(@plugin["network"]["settings"]['net.key.blockacq_count']).to eq('10') - expect(@plugin["network"]["settings"]['net.key.blockacq_lifetime']).to eq('20') - expect(@plugin["network"]["settings"]['net.key.esp_keymin']).to eq('256') - expect(@plugin["network"]["settings"]['net.key.esp_auth']).to eq('0') - expect(@plugin["network"]["settings"]['net.key.ah_keymin']).to eq('128') - expect(@plugin["network"]["settings"]['net.key.prefered_oldsa']).to eq('0') - expect(@plugin["network"]["settings"]['net.key.natt_keepalive_interval']).to eq('20') - expect(@plugin["network"]["settings"]['net.inet6.ip6.forwarding']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.redirect']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.hlim']).to eq('64') - expect(@plugin["network"]["settings"]['net.inet6.ip6.maxfragpackets']).to eq('1536') - expect(@plugin["network"]["settings"]['net.inet6.ip6.accept_rtadv']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.keepfaith']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.log_interval']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet6.ip6.hdrnestlimit']).to eq('15') - expect(@plugin["network"]["settings"]['net.inet6.ip6.dad_count']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.auto_flowlabel']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.defmcasthlim']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.gifhlim']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.kame_version']).to eq('2009/apple-darwin') - expect(@plugin["network"]["settings"]['net.inet6.ip6.use_deprecated']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.rr_prune']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet6.ip6.v6only']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.rtexpire']).to eq('3600') - expect(@plugin["network"]["settings"]['net.inet6.ip6.rtminexpire']).to eq('10') - expect(@plugin["network"]["settings"]['net.inet6.ip6.rtmaxcache']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet6.ip6.use_tempaddr']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.temppltime']).to eq('86400') - expect(@plugin["network"]["settings"]['net.inet6.ip6.tempvltime']).to eq('604800') - expect(@plugin["network"]["settings"]['net.inet6.ip6.auto_linklocal']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.prefer_tempaddr']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.use_defaultzone']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.maxfrags']).to eq('12288') - expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast_pmtu']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.neighborgcthresh']).to eq('1024') - expect(@plugin["network"]["settings"]['net.inet6.ip6.maxifprefixes']).to eq('16') - expect(@plugin["network"]["settings"]['net.inet6.ip6.maxifdefrouters']).to eq('16') - expect(@plugin["network"]["settings"]['net.inet6.ip6.maxdynroutes']).to eq('1024') - expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.enable']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.verbose']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.fw.verbose_limit']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.scopedroute']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.select_srcif_debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.maxgrpsrc']).to eq('512') - expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.maxsocksrc']).to eq('128') - expect(@plugin["network"]["settings"]['net.inet6.ip6.mcast.loop']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ip6.only_allow_rfc4193_prefixes']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.def_policy']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_trans_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_net_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ah_trans_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ah_net_deflev']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.ecn']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.ipsec6.esp_randpad']).to eq('-1') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.rediraccept']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.redirtimeout']).to eq('600') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_prune']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_delay']).to eq('5') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_umaxtries']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_mmaxtries']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_useloopback']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nodeinfo']).to eq('3') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.errppslimit']).to eq('500') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_maxnudhint']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_accept_6to4']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_onlink_ns_rfc4861']).to eq('0') - expect(@plugin["network"]["settings"]['net.inet6.icmp6.nd6_llreach_base']).to eq('30') - expect(@plugin["network"]["settings"]['net.inet6.mld.gsrdelay']).to eq('10') - expect(@plugin["network"]["settings"]['net.inet6.mld.v1enable']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.mld.use_allow']).to eq('1') - expect(@plugin["network"]["settings"]['net.inet6.mld.debug']).to eq('0') - expect(@plugin["network"]["settings"]['net.idle.route.expire_timeout']).to eq('30') - expect(@plugin["network"]["settings"]['net.idle.route.drain_interval']).to eq('10') - expect(@plugin["network"]["settings"]['net.statistics']).to eq('1') - expect(@plugin["network"]["settings"]['net.alf.loglevel']).to eq('55') - expect(@plugin["network"]["settings"]['net.alf.perm']).to eq('0') - expect(@plugin["network"]["settings"]['net.alf.defaultaction']).to eq('1') - expect(@plugin["network"]["settings"]['net.alf.mqcount']).to eq('0') - expect(@plugin["network"]["settings"]['net.smb.fs.version']).to eq('107000') - expect(@plugin["network"]["settings"]['net.smb.fs.loglevel']).to eq('0') - expect(@plugin["network"]["settings"]['net.smb.fs.kern_ntlmssp']).to eq('0') - expect(@plugin["network"]["settings"]['net.smb.fs.kern_deprecatePreXPServers']).to eq('1') - expect(@plugin["network"]["settings"]['net.smb.fs.kern_deadtimer']).to eq('60') - expect(@plugin["network"]["settings"]['net.smb.fs.kern_hard_deadtimer']).to eq('600') - expect(@plugin["network"]["settings"]['net.smb.fs.kern_soft_deadtimer']).to eq('30') - expect(@plugin["network"]["settings"]['net.smb.fs.tcpsndbuf']).to eq('261120') - expect(@plugin["network"]["settings"]['net.smb.fs.tcprcvbuf']).to eq('261120') + expect(@plugin["network"]["settings"]["net.local.stream.sendspace"]).to eq("8192") + expect(@plugin["network"]["settings"]["net.local.stream.recvspace"]).to eq("8192") + expect(@plugin["network"]["settings"]["net.local.stream.tracemdns"]).to eq("0") + expect(@plugin["network"]["settings"]["net.local.dgram.maxdgram"]).to eq("2048") + expect(@plugin["network"]["settings"]["net.local.dgram.recvspace"]).to eq("4096") + expect(@plugin["network"]["settings"]["net.local.inflight"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.lowfirst"]).to eq("1023") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.lowlast"]).to eq("600") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.first"]).to eq("49152") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.last"]).to eq("65535") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.hifirst"]).to eq("49152") + expect(@plugin["network"]["settings"]["net.inet.ip.portrange.hilast"]).to eq("65535") + expect(@plugin["network"]["settings"]["net.inet.ip.forwarding"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.redirect"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.ttl"]).to eq("64") + expect(@plugin["network"]["settings"]["net.inet.ip.rtexpire"]).to eq("12") + expect(@plugin["network"]["settings"]["net.inet.ip.rtminexpire"]).to eq("10") + expect(@plugin["network"]["settings"]["net.inet.ip.rtmaxcache"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet.ip.sourceroute"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.intr_queue_maxlen"]).to eq("50") + expect(@plugin["network"]["settings"]["net.inet.ip.intr_queue_drops"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.accept_sourceroute"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.keepfaith"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.gifttl"]).to eq("30") + expect(@plugin["network"]["settings"]["net.inet.ip.subnets_are_local"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.mcast.maxgrpsrc"]).to eq("512") + expect(@plugin["network"]["settings"]["net.inet.ip.mcast.maxsocksrc"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet.ip.mcast.loop"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.check_route_selfref"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.use_route_genid"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.hash_size"]).to eq("64") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.curr_time"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.ready_heap"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.extract_heap"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.searches"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.search_steps"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.expire"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.max_chain_len"]).to eq("16") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_lookup_depth"]).to eq("256") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_avg_pkt_size"]).to eq("512") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.red_max_pkt_size"]).to eq("1500") + expect(@plugin["network"]["settings"]["net.inet.ip.dummynet.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.enable"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.autoinc_step"]).to eq("100") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.one_pass"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.verbose"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.verbose_limit"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_buckets"]).to eq("256") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.curr_dyn_buckets"]).to eq("256") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_count"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_max"]).to eq("4096") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.static_count"]).to eq("2") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_ack_lifetime"]).to eq("300") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_syn_lifetime"]).to eq("20") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_fin_lifetime"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_rst_lifetime"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_udp_lifetime"]).to eq("10") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_short_lifetime"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet.ip.fw.dyn_keepalive"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.maxfragpackets"]).to eq("1536") + expect(@plugin["network"]["settings"]["net.inet.ip.maxfragsperpacket"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet.ip.maxfrags"]).to eq("3072") + expect(@plugin["network"]["settings"]["net.inet.ip.scopedroute"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.check_interface"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.linklocal.in.allowbadttl"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.random_id"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ip.maxchainsent"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ip.select_srcif_debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.icmp.maskrepl"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.icmp.icmplim"]).to eq("250") + expect(@plugin["network"]["settings"]["net.inet.icmp.timestamp"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.icmp.drop_redirect"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.icmp.log_redirect"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.icmp.bmcastecho"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.recvifkludge"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.sendra"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.sendlocal"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.v1enable"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.v2enable"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.igmp.legacysupp"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.igmp.default_version"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet.igmp.gsrdelay"]).to eq("10") + expect(@plugin["network"]["settings"]["net.inet.igmp.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.rfc1323"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.rfc1644"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.mssdflt"]).to eq("512") + expect(@plugin["network"]["settings"]["net.inet.tcp.keepidle"]).to eq("7200000") + expect(@plugin["network"]["settings"]["net.inet.tcp.keepintvl"]).to eq("75000") + expect(@plugin["network"]["settings"]["net.inet.tcp.sendspace"]).to eq("65536") + expect(@plugin["network"]["settings"]["net.inet.tcp.recvspace"]).to eq("65536") + expect(@plugin["network"]["settings"]["net.inet.tcp.keepinit"]).to eq("75000") + expect(@plugin["network"]["settings"]["net.inet.tcp.v6mssdflt"]).to eq("1024") + expect(@plugin["network"]["settings"]["net.inet.tcp.log_in_vain"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.blackhole"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.delayed_ack"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_lq_overflow"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.recvbg"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.drop_synfin"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.reass.maxsegments"]).to eq("3072") + expect(@plugin["network"]["settings"]["net.inet.tcp.reass.cursegments"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.reass.overflows"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.slowlink_wsize"]).to eq("8192") + expect(@plugin["network"]["settings"]["net.inet.tcp.maxseg_unacked"]).to eq("8") + expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3465"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3465_lim2"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.rtt_samples_per_slot"]).to eq("20") + expect(@plugin["network"]["settings"]["net.inet.tcp.recv_allowed_iaj"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet.tcp.acc_iaj_high_thresh"]).to eq("100") + expect(@plugin["network"]["settings"]["net.inet.tcp.rexmt_thresh"]).to eq("2") + expect(@plugin["network"]["settings"]["net.inet.tcp.path_mtu_discovery"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.slowstart_flightsize"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.local_slowstart_flightsize"]).to eq("8") + expect(@plugin["network"]["settings"]["net.inet.tcp.tso"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.ecn_initiate_out"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.ecn_negotiate_in"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.packetchain"]).to eq("50") + expect(@plugin["network"]["settings"]["net.inet.tcp.socket_unlocked_on_output"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.rfc3390"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.min_iaj_win"]).to eq("4") + expect(@plugin["network"]["settings"]["net.inet.tcp.acc_iaj_react_limit"]).to eq("200") + expect(@plugin["network"]["settings"]["net.inet.tcp.sack"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.sack_maxholes"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet.tcp.sack_globalmaxholes"]).to eq("65536") + expect(@plugin["network"]["settings"]["net.inet.tcp.sack_globalholes"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.minmss"]).to eq("216") + expect(@plugin["network"]["settings"]["net.inet.tcp.minmssoverload"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.do_tcpdrain"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.pcbcount"]).to eq("86") + expect(@plugin["network"]["settings"]["net.inet.tcp.icmp_may_rst"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.strict_rfc1948"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.isn_reseed_interval"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.background_io_enabled"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.rtt_min"]).to eq("100") + expect(@plugin["network"]["settings"]["net.inet.tcp.rexmt_slop"]).to eq("200") + expect(@plugin["network"]["settings"]["net.inet.tcp.randomize_ports"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.newreno_sockets"]).to eq("81") + expect(@plugin["network"]["settings"]["net.inet.tcp.background_sockets"]).to eq("-1") + expect(@plugin["network"]["settings"]["net.inet.tcp.tcbhashsize"]).to eq("4096") + expect(@plugin["network"]["settings"]["net.inet.tcp.background_io_trigger"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet.tcp.msl"]).to eq("15000") + expect(@plugin["network"]["settings"]["net.inet.tcp.max_persist_timeout"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.always_keepalive"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.tcp.timer_fastmode_idlemax"]).to eq("20") + expect(@plugin["network"]["settings"]["net.inet.tcp.broken_peer_syn_rxmit_thres"]).to eq("7") + expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_timer_advanced"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet.tcp.tcp_resched_timerlist"]).to eq("12209") + expect(@plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_detection"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.pmtud_blackhole_mss"]).to eq("1200") + expect(@plugin["network"]["settings"]["net.inet.tcp.timer_fastquantum"]).to eq("100") + expect(@plugin["network"]["settings"]["net.inet.tcp.timer_slowquantum"]).to eq("500") + expect(@plugin["network"]["settings"]["net.inet.tcp.win_scale_factor"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet.tcp.sockthreshold"]).to eq("64") + expect(@plugin["network"]["settings"]["net.inet.tcp.bg_target_qdelay"]).to eq("100") + expect(@plugin["network"]["settings"]["net.inet.tcp.bg_allowed_increase"]).to eq("2") + expect(@plugin["network"]["settings"]["net.inet.tcp.bg_tether_shift"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.tcp.bg_ss_fltsz"]).to eq("2") + expect(@plugin["network"]["settings"]["net.inet.udp.checksum"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.udp.maxdgram"]).to eq("9216") + expect(@plugin["network"]["settings"]["net.inet.udp.recvspace"]).to eq("42080") + expect(@plugin["network"]["settings"]["net.inet.udp.log_in_vain"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.udp.blackhole"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.udp.pcbcount"]).to eq("72") + expect(@plugin["network"]["settings"]["net.inet.udp.randomize_ports"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.def_policy"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_trans_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_net_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_trans_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_net_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_cleartos"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.ah_offsetmask"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ipsec.dfbit"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ipsec.ecn"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ipsec.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_randpad"]).to eq("-1") + expect(@plugin["network"]["settings"]["net.inet.ipsec.bypass"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet.ipsec.esp_port"]).to eq("4500") + expect(@plugin["network"]["settings"]["net.inet.raw.maxdgram"]).to eq("8192") + expect(@plugin["network"]["settings"]["net.inet.raw.recvspace"]).to eq("8192") + expect(@plugin["network"]["settings"]["net.link.generic.system.ifcount"]).to eq("10") + expect(@plugin["network"]["settings"]["net.link.generic.system.dlil_verbose"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.generic.system.multi_threaded_input"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.generic.system.dlil_input_sanity_check"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.ether.inet.prune_intvl"]).to eq("300") + expect(@plugin["network"]["settings"]["net.link.ether.inet.max_age"]).to eq("1200") + expect(@plugin["network"]["settings"]["net.link.ether.inet.host_down_time"]).to eq("20") + expect(@plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_tx"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.ether.inet.apple_hwcksum_rx"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.ether.inet.arp_llreach_base"]).to eq("30") + expect(@plugin["network"]["settings"]["net.link.ether.inet.maxtries"]).to eq("5") + expect(@plugin["network"]["settings"]["net.link.ether.inet.useloopback"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.ether.inet.proxyall"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.ether.inet.sendllconflict"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.ether.inet.log_arp_warnings"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.ether.inet.keep_announcements"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.ether.inet.send_conflicting_probes"]).to eq("1") + expect(@plugin["network"]["settings"]["net.link.bridge.log_stp"]).to eq("0") + expect(@plugin["network"]["settings"]["net.link.bridge.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.key.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.key.spi_trycnt"]).to eq("1000") + expect(@plugin["network"]["settings"]["net.key.spi_minval"]).to eq("256") + expect(@plugin["network"]["settings"]["net.key.spi_maxval"]).to eq("268435455") + expect(@plugin["network"]["settings"]["net.key.int_random"]).to eq("60") + expect(@plugin["network"]["settings"]["net.key.larval_lifetime"]).to eq("30") + expect(@plugin["network"]["settings"]["net.key.blockacq_count"]).to eq("10") + expect(@plugin["network"]["settings"]["net.key.blockacq_lifetime"]).to eq("20") + expect(@plugin["network"]["settings"]["net.key.esp_keymin"]).to eq("256") + expect(@plugin["network"]["settings"]["net.key.esp_auth"]).to eq("0") + expect(@plugin["network"]["settings"]["net.key.ah_keymin"]).to eq("128") + expect(@plugin["network"]["settings"]["net.key.prefered_oldsa"]).to eq("0") + expect(@plugin["network"]["settings"]["net.key.natt_keepalive_interval"]).to eq("20") + expect(@plugin["network"]["settings"]["net.inet6.ip6.forwarding"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.redirect"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.hlim"]).to eq("64") + expect(@plugin["network"]["settings"]["net.inet6.ip6.maxfragpackets"]).to eq("1536") + expect(@plugin["network"]["settings"]["net.inet6.ip6.accept_rtadv"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.keepfaith"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.log_interval"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet6.ip6.hdrnestlimit"]).to eq("15") + expect(@plugin["network"]["settings"]["net.inet6.ip6.dad_count"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.auto_flowlabel"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.defmcasthlim"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.gifhlim"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.kame_version"]).to eq("2009/apple-darwin") + expect(@plugin["network"]["settings"]["net.inet6.ip6.use_deprecated"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.rr_prune"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet6.ip6.v6only"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.rtexpire"]).to eq("3600") + expect(@plugin["network"]["settings"]["net.inet6.ip6.rtminexpire"]).to eq("10") + expect(@plugin["network"]["settings"]["net.inet6.ip6.rtmaxcache"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet6.ip6.use_tempaddr"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.temppltime"]).to eq("86400") + expect(@plugin["network"]["settings"]["net.inet6.ip6.tempvltime"]).to eq("604800") + expect(@plugin["network"]["settings"]["net.inet6.ip6.auto_linklocal"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.prefer_tempaddr"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.use_defaultzone"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.maxfrags"]).to eq("12288") + expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast_pmtu"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.neighborgcthresh"]).to eq("1024") + expect(@plugin["network"]["settings"]["net.inet6.ip6.maxifprefixes"]).to eq("16") + expect(@plugin["network"]["settings"]["net.inet6.ip6.maxifdefrouters"]).to eq("16") + expect(@plugin["network"]["settings"]["net.inet6.ip6.maxdynroutes"]).to eq("1024") + expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.enable"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.verbose"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.fw.verbose_limit"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.scopedroute"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.select_srcif_debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.maxgrpsrc"]).to eq("512") + expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.maxsocksrc"]).to eq("128") + expect(@plugin["network"]["settings"]["net.inet6.ip6.mcast.loop"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ip6.only_allow_rfc4193_prefixes"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.def_policy"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_trans_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_net_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ah_trans_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ah_net_deflev"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.ecn"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.ipsec6.esp_randpad"]).to eq("-1") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.rediraccept"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.redirtimeout"]).to eq("600") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_prune"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_delay"]).to eq("5") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_umaxtries"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_mmaxtries"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_useloopback"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nodeinfo"]).to eq("3") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.errppslimit"]).to eq("500") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_maxnudhint"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_accept_6to4"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_onlink_ns_rfc4861"]).to eq("0") + expect(@plugin["network"]["settings"]["net.inet6.icmp6.nd6_llreach_base"]).to eq("30") + expect(@plugin["network"]["settings"]["net.inet6.mld.gsrdelay"]).to eq("10") + expect(@plugin["network"]["settings"]["net.inet6.mld.v1enable"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.mld.use_allow"]).to eq("1") + expect(@plugin["network"]["settings"]["net.inet6.mld.debug"]).to eq("0") + expect(@plugin["network"]["settings"]["net.idle.route.expire_timeout"]).to eq("30") + expect(@plugin["network"]["settings"]["net.idle.route.drain_interval"]).to eq("10") + expect(@plugin["network"]["settings"]["net.statistics"]).to eq("1") + expect(@plugin["network"]["settings"]["net.alf.loglevel"]).to eq("55") + expect(@plugin["network"]["settings"]["net.alf.perm"]).to eq("0") + expect(@plugin["network"]["settings"]["net.alf.defaultaction"]).to eq("1") + expect(@plugin["network"]["settings"]["net.alf.mqcount"]).to eq("0") + expect(@plugin["network"]["settings"]["net.smb.fs.version"]).to eq("107000") + expect(@plugin["network"]["settings"]["net.smb.fs.loglevel"]).to eq("0") + expect(@plugin["network"]["settings"]["net.smb.fs.kern_ntlmssp"]).to eq("0") + expect(@plugin["network"]["settings"]["net.smb.fs.kern_deprecatePreXPServers"]).to eq("1") + expect(@plugin["network"]["settings"]["net.smb.fs.kern_deadtimer"]).to eq("60") + expect(@plugin["network"]["settings"]["net.smb.fs.kern_hard_deadtimer"]).to eq("600") + expect(@plugin["network"]["settings"]["net.smb.fs.kern_soft_deadtimer"]).to eq("30") + expect(@plugin["network"]["settings"]["net.smb.fs.tcpsndbuf"]).to eq("261120") + expect(@plugin["network"]["settings"]["net.smb.fs.tcprcvbuf"]).to eq("261120") end end end diff --git a/spec/unit/plugins/darwin/platform_spec.rb b/spec/unit/plugins/darwin/platform_spec.rb index 6cc43558..53a8ff21 100644 --- a/spec/unit/plugins/darwin/platform_spec.rb +++ b/spec/unit/plugins/darwin/platform_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin plugin platform" do before(:each) do diff --git a/spec/unit/plugins/darwin/system_profiler_spec.rb b/spec/unit/plugins/darwin/system_profiler_spec.rb index f108445d..98b6c845 100644 --- a/spec/unit/plugins/darwin/system_profiler_spec.rb +++ b/spec/unit/plugins/darwin/system_profiler_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") require File.expand_path("#{File.dirname(__FILE__)}/system_profiler_output.rb") begin - require 'plist' + require "plist" rescue LoadError => e puts "The darwin systemprofile plugin spec tests will fail without the 'plist' library/gem.\n\n" raise e @@ -42,6 +42,6 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do allow(@plugin).to receive(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, "")) allow(@plugin).to receive(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, "")) @plugin.run - expect(@plugin['system_profile'][18]["_items"][0]["serial_number"]).to eq('ABCDEFG12345') + expect(@plugin["system_profile"][18]["_items"][0]["serial_number"]).to eq("ABCDEFG12345") end end diff --git a/spec/unit/plugins/darwin/virtualization_spec.rb b/spec/unit/plugins/darwin/virtualization_spec.rb index 86487e9a..10021a72 100644 --- a/spec/unit/plugins/darwin/virtualization_spec.rb +++ b/spec/unit/plugins/darwin/virtualization_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Darwin virtualization platform" do - let(:plugin) { get_plugin("darwin/virtualization")} + let(:plugin) { get_plugin("darwin/virtualization") } before(:each) do allow(plugin).to receive(:collect_os).and_return(:darwin) @@ -38,12 +38,12 @@ describe Ohai::System, "Darwin virtualization platform" do it "should not set parallels host if /usr/bin/prlctl not exist" do allow(plugin).to receive(:prlctl_exists?).and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end it "should set parallels guest if /usr/sbin/ioreg exists and it's output contains pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) - ioreg=<<-IOREG + ioreg = <<-IOREG | | +-o pci1ab8,4000@3 | | | | { | | | | "compatible" = <"pci1ab8,400","pci1ab8,4000","pciclass,ff0000"> @@ -77,7 +77,7 @@ describe Ohai::System, "Darwin virtualization platform" do it "should not set parallels guest if /usr/sbin/ioreg exists and it's output not contain pci1ab8,4000" do allow(plugin).to receive(:ioreg_exists?).and_return(true) - ioreg=<<-IOREG + ioreg = <<-IOREG | | +-o pci8086,2445@1F,4 | | | { | | | "compatible" = <"pci1ab8,400","pci8086,2445","pciclass,040100"> @@ -103,7 +103,7 @@ describe Ohai::System, "Darwin virtualization platform" do allow(shellout).to receive(:stdout).and_return(ioreg) allow(plugin).to receive(:shell_out).with("ioreg -l").and_return(shellout) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end end diff --git a/spec/unit/plugins/digital_ocean_spec.rb b/spec/unit/plugins/digital_ocean_spec.rb index eb2742de..09b1f8c4 100644 --- a/spec/unit/plugins/digital_ocean_spec.rb +++ b/spec/unit/plugins/digital_ocean_spec.rb @@ -15,13 +15,13 @@ # limitations under the License. # -require 'ipaddress' -require 'spec_helper' +require "ipaddress" +require "spec_helper" describe Ohai::System, "plugin digital_ocean" do - let(:hint_path_nix) { '/etc/chef/ohai/hints/digital_ocean.json' } + let(:hint_path_nix) { "/etc/chef/ohai/hints/digital_ocean.json" } let(:hint_path_win) { 'C:\chef\ohai\hints/digital_ocean.json' } - let(:digitalocean_path) { '/etc/digitalocean' } + let(:digitalocean_path) { "/etc/digitalocean" } let(:hint) { '{ "droplet_id": 12345678, @@ -39,13 +39,13 @@ describe Ohai::System, "plugin digital_ocean" do before do @plugin = get_plugin("digital_ocean") @plugin[:network] = { - "interfaces"=> { - "eth0"=> { - "addresses"=> { - "1.2.3.4"=> { - "netmask"=> "255.255.255.0" + "interfaces" => { + "eth0" => { + "addresses" => { + "1.2.3.4" => { + "netmask" => "255.255.255.0" }, - "2400:6180:0000:00d0:0000:0000:0009:7001"=> {} + "2400:6180:0000:00d0:0000:0000:0009:7001" => {}, } } } @@ -57,8 +57,7 @@ describe Ohai::System, "plugin digital_ocean" do allow(File).to receive(:read).with(hint_path_win).and_return(hint) end - - shared_examples_for "!digital_ocean" do + shared_examples_for "!digital_ocean" do before(:each) do @plugin.run end @@ -74,12 +73,12 @@ describe Ohai::System, "plugin digital_ocean" do end it "pulls ip addresses from the network interfaces" do - expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{"ip_address" => "1.2.3.4", - "type" => "public", - "netmask" => "255.255.255.0"}]) - expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{"ip_address"=>"2400:6180:0000:00d0:0000:0000:0009:7001", - "type"=>"public", - "cidr"=>128}]) + expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{ "ip_address" => "1.2.3.4", + "type" => "public", + "netmask" => "255.255.255.0" }]) + expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{ "ip_address" => "2400:6180:0000:00d0:0000:0000:0009:7001", + "type" => "public", + "cidr" => 128 }]) end end @@ -112,7 +111,7 @@ describe Ohai::System, "plugin digital_ocean" do expect(@plugin[:digital_ocean][:region_id]).to eq(4) end - include_examples 'digital_ocean_networking' + include_examples "digital_ocean_networking" end describe "with digital_ocean hint file" do @@ -128,11 +127,11 @@ describe Ohai::System, "plugin digital_ocean" do context "with private networking enabled" do before do @plugin[:network][:interfaces][:eth1] = { - "addresses"=> { + "addresses" => { "10.128.142.89" => { "netmask" => "255.255.255.0" }, - "fdf8:f53b:82e4:0000:0000:0000:0000:0053" => {} + "fdf8:f53b:82e4:0000:0000:0000:0000:0053" => {}, } } @@ -140,18 +139,18 @@ describe Ohai::System, "plugin digital_ocean" do end it "should extract the private networking ips" do - expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{"ip_address" => "1.2.3.4", - "type" => "public", - "netmask" => "255.255.255.0"}, - {"ip_address" => "10.128.142.89", - "type" => "private", - "netmask" => "255.255.255.0"}]) - expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{"ip_address"=>"2400:6180:0000:00d0:0000:0000:0009:7001", - "type"=>"public", - "cidr"=>128}, - {"ip_address"=>"fdf8:f53b:82e4:0000:0000:0000:0000:0053", - "type"=>"private", - "cidr"=>128}]) + expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{ "ip_address" => "1.2.3.4", + "type" => "public", + "netmask" => "255.255.255.0" }, + { "ip_address" => "10.128.142.89", + "type" => "private", + "netmask" => "255.255.255.0" }]) + expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{ "ip_address" => "2400:6180:0000:00d0:0000:0000:0009:7001", + "type" => "public", + "cidr" => 128 }, + { "ip_address" => "fdf8:f53b:82e4:0000:0000:0000:0000:0053", + "type" => "private", + "cidr" => 128 }]) end end end @@ -162,7 +161,6 @@ describe Ohai::System, "plugin digital_ocean" do allow(File).to receive(:exist?).with(hint_path_win).and_return(false) end - describe "with the /etc/digitalocean file" do before do allow(File).to receive(:exist?).with(digitalocean_path).and_return(true) @@ -180,7 +178,7 @@ describe Ohai::System, "plugin digital_ocean" do end context "with ec2 hint file" do - let(:ec2_hint_path_nix) { '/etc/chef/ohai/hints/ec2.json' } + let(:ec2_hint_path_nix) { "/etc/chef/ohai/hints/ec2.json" } let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' } before do @@ -188,9 +186,9 @@ describe Ohai::System, "plugin digital_ocean" do allow(File).to receive(:exist?).with(hint_path_win).and_return(false) allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true) - allow(File).to receive(:read).with(ec2_hint_path_nix).and_return('') + allow(File).to receive(:read).with(ec2_hint_path_nix).and_return("") allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true) - allow(File).to receive(:read).with(ec2_hint_path_win).and_return('') + allow(File).to receive(:read).with(ec2_hint_path_win).and_return("") end describe "with the /etc/digitalocean file" do diff --git a/spec/unit/plugins/ec2_spec.rb b/spec/unit/plugins/ec2_spec.rb index 4c971509..18a08ee9 100644 --- a/spec/unit/plugins/ec2_spec.rb +++ b/spec/unit/plugins/ec2_spec.rb @@ -17,17 +17,17 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'open-uri' -require 'base64' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "open-uri" +require "base64" describe Ohai::System, "plugin ec2" do before(:each) do @plugin = get_plugin("ec2") - @plugin[:network] = {:interfaces => {:eth0 => {} } } - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) + @plugin[:network] = { :interfaces => { :eth0 => {} } } + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/bin/ec2metadata').and_return(false) + allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(false) end shared_examples_for "!ec2" do @@ -42,7 +42,7 @@ describe Ohai::System, "plugin ec2" do before(:each) do @http_client = double("Net::HTTP client") allow(@plugin).to receive(:http_client).and_return(@http_client) - allow(IO).to receive(:select).and_return([[],[1],[]]) + allow(IO).to receive(:select).and_return([[], [1], []]) t = double("connection") allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS) allow(Socket).to receive(:new).and_return(t) @@ -56,12 +56,12 @@ describe Ohai::System, "plugin ec2" do { "meta-data/" => "instance_type\nami_id\nsecurity-groups", "meta-data/instance_type" => "c1.medium", "meta-data/ami_id" => "ami-5d2dc934", - "meta-data/security-groups" => "group1\ngroup2" + "meta-data/security-groups" => "group1\ngroup2", } end it "recursively fetches all the ec2 metadata" do - paths.each do |name,body| + paths.each do |name, body| expect(@http_client).to receive(:get). with("/2012-01-12/#{name}"). and_return(double("Net::HTTP Response", :body => body, :code => "200")) @@ -73,13 +73,13 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['instance_type']).to eq("c1.medium") - expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934") - expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2'] + expect(@plugin[:ec2]["instance_type"]).to eq("c1.medium") + expect(@plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934") + expect(@plugin[:ec2]["security_groups"]).to eql %w{group1 group2} end it "fetches binary userdata opaquely" do - paths.each do |name,body| + paths.each do |name, body| expect(@http_client).to receive(:get). with("/2012-01-12/#{name}"). and_return(double("Net::HTTP Response", :body => body, :code => "200")) @@ -91,10 +91,10 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['instance_type']).to eq("c1.medium") - expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934") - expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2'] - expect(@plugin[:ec2]['userdata']).to eq(Base64.decode64("Xl88OEI+XkheSDxDNz5VXkBeQ3NvbWV0aGluZ15AS1Q8Qzg+PEM5PiwpPEM5\nPklVKEktLkk8Q0I+PENDPkk8RTU+XkJeQF5RejxCRj48QjA+XlJeQF5AXkA=")) + expect(@plugin[:ec2]["instance_type"]).to eq("c1.medium") + expect(@plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934") + expect(@plugin[:ec2]["security_groups"]).to eql %w{group1 group2} + expect(@plugin[:ec2]["userdata"]).to eq(Base64.decode64("Xl88OEI+XkheSDxDNz5VXkBeQ3NvbWV0aGluZ15AS1Q8Qzg+PEM5PiwpPEM5\nPklVKEktLkk8Q0I+PENDPkk8RTU+XkJeQF5RejxCRj48QjA+XlJeQF5AXkA=")) end end @@ -124,17 +124,17 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname']).to eql('server17.opscode.com') + expect(@plugin[:ec2]["network_interfaces_macs"]["12:34:56:78:9a:bc"]["public_hostname"]).to eql("server17.opscode.com") end # context with common metadata paths context "with ec2_iam hint file" do before do if windows? allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return("") else - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/iam.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/iam.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/iam.json").and_return("") end end @@ -158,8 +158,8 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Code']).to eql 'Success' - expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Token']).to eql '12345678' + expect(@plugin[:ec2]["iam"]["security-credentials"]["MyRole"]["Code"]).to eql "Success" + expect(@plugin[:ec2]["iam"]["security-credentials"]["MyRole"]["Token"]).to eql "12345678" end end @@ -168,7 +168,7 @@ describe Ohai::System, "plugin ec2" do if windows? allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false) else - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/iam.json").and_return(false) end end @@ -192,7 +192,7 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['iam']).to be_nil + expect(@plugin[:ec2]["iam"]).to be_nil end end @@ -250,15 +250,15 @@ describe Ohai::System, "plugin ec2" do @plugin.run expect(@plugin[:ec2]).not_to be_nil - expect(@plugin[:ec2]['metrics']).to be_nil - expect(@plugin[:ec2]['metrics_vhostmd']).to be_nil + expect(@plugin[:ec2]["metrics"]).to be_nil + expect(@plugin[:ec2]["metrics_vhostmd"]).to be_nil end end # shared examples for ec2 describe "without dmi or ec2metadata binary, with xen mac, and metadata address connected" do before(:each) do - allow(IO).to receive(:select).and_return([[],[1],[]]) - @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"} + allow(IO).to receive(:select).and_return([[], [1], []]) + @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "fe:ff:ff:ff:ff:ff" } end it_should_behave_like "ec2" @@ -273,7 +273,7 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "ec2" before(:each) do - allow(File).to receive(:exist?).with('/usr/bin/ec2metadata').and_return(true) + allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(true) end end @@ -281,7 +281,7 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "ec2" before(:each) do - @plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } } + @plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } } end end @@ -291,10 +291,10 @@ describe Ohai::System, "plugin ec2" do before(:each) do if windows? expect(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("") else - expect(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + expect(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("") end end end @@ -303,10 +303,10 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "!ec2" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("") end end @@ -314,11 +314,11 @@ describe Ohai::System, "plugin ec2" do it_should_behave_like "!ec2" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false) - allow(File).to receive(:exist?).with('/usr/bin/ec2metadata').and_return(false) + allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(false) @plugin[:dmi] = nil - @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"00:50:56:c0:00:08"} + @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "00:50:56:c0:00:08" } end end diff --git a/spec/unit/plugins/elixir_spec.rb b/spec/unit/plugins/elixir_spec.rb index 3888e03d..a82c8179 100644 --- a/spec/unit/plugins/elixir_spec.rb +++ b/spec/unit/plugins/elixir_spec.rb @@ -14,7 +14,7 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin elixir" do @@ -43,4 +43,3 @@ describe Ohai::System, "plugin elixir" do end end - diff --git a/spec/unit/plugins/erlang_spec.rb b/spec/unit/plugins/erlang_spec.rb index cdcd199a..cdb0a340 100644 --- a/spec/unit/plugins/erlang_spec.rb +++ b/spec/unit/plugins/erlang_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin erlang" do @@ -40,7 +40,7 @@ describe Ohai::System, "plugin erlang" do it "should set languages[:erlang][:options]" do @plugin.run - expect(@plugin.languages[:erlang][:options]).to eql(["ASYNC_THREADS", "SMP", "HIPE"]) + expect(@plugin.languages[:erlang][:options]).to eql(%w{ASYNC_THREADS SMP HIPE}) end it "should set languages[:erlang][:emulator]" do diff --git a/spec/unit/plugins/eucalyptus_spec.rb b/spec/unit/plugins/eucalyptus_spec.rb index ee964bf1..89a877d3 100644 --- a/spec/unit/plugins/eucalyptus_spec.rb +++ b/spec/unit/plugins/eucalyptus_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'open-uri' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "open-uri" describe Ohai::System, "plugin eucalyptus" do before(:each) do @@ -58,15 +58,15 @@ describe Ohai::System, "plugin eucalyptus" do end it "should recursively fetch all the eucalyptus metadata" do - allow(IO).to receive(:select).and_return([[],[1],[]]) + allow(IO).to receive(:select).and_return([[], [1], []]) t = double("connection") allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS) allow(Socket).to receive(:new).and_return(t) @plugin.run expect(@plugin[:eucalyptus]).not_to be_nil - expect(@plugin[:eucalyptus]['instance_type']).to eq("c1.medium") - expect(@plugin[:eucalyptus]['ami_id']).to eq("ami-5d2dc934") - expect(@plugin[:eucalyptus]['security_groups']).to eql ['group1', 'group2'] + expect(@plugin[:eucalyptus]["instance_type"]).to eq("c1.medium") + expect(@plugin[:eucalyptus]["ami_id"]).to eq("ami-5d2dc934") + expect(@plugin[:eucalyptus]["security_groups"]).to eql %w{group1 group2} end end @@ -74,8 +74,8 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "eucalyptus" before(:each) do - allow(IO).to receive(:select).and_return([[],[1],[]]) - @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED"=> { "family" => "lladdr" } } } } } + allow(IO).to receive(:select).and_return([[], [1], []]) + @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } } end end @@ -83,7 +83,7 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "!eucalyptus" before(:each) do - @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED"=> { "family" => "lladdr" } } } } } + @plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } } end end @@ -91,10 +91,10 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "eucalyptus" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/eucalyptus.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/eucalyptus.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/eucalyptus.json').and_return("") end end @@ -102,8 +102,8 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "!eucalyptus" before(:each) do - @plugin[:network] = {:interfaces => {}} - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) + @plugin[:network] = { :interfaces => {} } + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) end end @@ -112,14 +112,14 @@ describe Ohai::System, "plugin eucalyptus" do it_should_behave_like "!eucalyptus" before(:each) do - @plugin[:network] = {:interfaces => {}} + @plugin[:network] = { :interfaces => {} } - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/eucalyptus.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/eucalyptus.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/eucalyptus.json').and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') - allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("") + allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("") end end diff --git a/spec/unit/plugins/fail_spec.rb b/spec/unit/plugins/fail_spec.rb index 19bfa71c..763dc266 100644 --- a/spec/unit/plugins/fail_spec.rb +++ b/spec/unit/plugins/fail_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) -tmp = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp' +tmp = ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp" shared_examples "a v7 loading failure" do before(:all) do diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb index a895b395..1dbbf3a6 100644 --- a/spec/unit/plugins/freebsd/cpu_spec.rb +++ b/spec/unit/plugins/freebsd/cpu_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do before(:each) do @@ -24,20 +24,20 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do allow(@plugin).to receive(:collect_os).and_return(:freebsd) @double_file = double("/var/run/dmesg.boot") allow(@double_file).to receive(:each). - and_yield('CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (2793.59-MHz K8-class CPU)'). + and_yield("CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (2793.59-MHz K8-class CPU)"). and_yield(' Origin="GenuineIntel" Id=0x40661 Family=0x6 Model=0x46 Stepping=1'). - and_yield(' Features=0x783fbff'). - and_yield(' Features2=0x5ed8220b'). - and_yield(' AMD Features=0x28100800'). - and_yield(' AMD Features2=0x21'). - and_yield(' Structured Extended Features=0x2000'). - and_yield(' TSC: P-state invariant'). - and_yield('real memory = 1073676288 (1023 MB)'). - and_yield('avail memory = 1010253824 (963 MB)'). + and_yield(" Features=0x783fbff"). + and_yield(" Features2=0x5ed8220b"). + and_yield(" AMD Features=0x28100800"). + and_yield(" AMD Features2=0x21"). + and_yield(" Structured Extended Features=0x2000"). + and_yield(" TSC: P-state invariant"). + and_yield("real memory = 1073676288 (1023 MB)"). + and_yield("avail memory = 1010253824 (963 MB)"). and_yield('Event timer "LAPIC" quality 400'). - and_yield('ACPI APIC Table: '). - and_yield('FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs'). - and_yield('FreeBSD/SMP: 2 package(s) x 4 core(s) x 2 SMT threads') + and_yield("ACPI APIC Table: "). + and_yield("FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs"). + and_yield("FreeBSD/SMP: 2 package(s) x 4 core(s) x 2 SMT threads") allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file) end @@ -100,7 +100,7 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", "")) @double_file = double("/var/run/dmesg.boot") allow(@double_file).to receive(:each). - and_yield('CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (1596.03-MHz 686-class CPU)'). + and_yield("CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (1596.03-MHz 686-class CPU)"). and_yield(' Origin = "GenuineIntel" Id = 0x106c2 Family = 0x6 Model = 0x1c Stepping = 2') allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file) end diff --git a/spec/unit/plugins/freebsd/hostname_spec.rb b/spec/unit/plugins/freebsd/hostname_spec.rb index 9d4c4a00..a1279b20 100644 --- a/spec/unit/plugins/freebsd/hostname_spec.rb +++ b/spec/unit/plugins/freebsd/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD hostname plugin" do before(:each) do diff --git a/spec/unit/plugins/freebsd/kernel_spec.rb b/spec/unit/plugins/freebsd/kernel_spec.rb index 2040b67f..d9baf8fc 100644 --- a/spec/unit/plugins/freebsd/kernel_spec.rb +++ b/spec/unit/plugins/freebsd/kernel_spec.rb @@ -16,14 +16,13 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD kernel plugin" do before(:each) do @plugin = get_plugin("kernel") allow(@plugin).to receive(:collect_os).and_return(:freebsd) - allow(@plugin).to receive(:init_kernel).and_return({:name => "freebsd"}) + allow(@plugin).to receive(:init_kernel).and_return({ :name => "freebsd" }) allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", "")) allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", "")) allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", "")) diff --git a/spec/unit/plugins/freebsd/os_spec.rb b/spec/unit/plugins/freebsd/os_spec.rb index bbc9b6b8..dfb89996 100644 --- a/spec/unit/plugins/freebsd/os_spec.rb +++ b/spec/unit/plugins/freebsd/os_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD plugin os" do before(:each) do @@ -30,4 +29,4 @@ describe Ohai::System, "FreeBSD plugin os" do @plugin.run expect(@plugin[:os_version]).to eq("902001") end -end +end diff --git a/spec/unit/plugins/freebsd/platform_spec.rb b/spec/unit/plugins/freebsd/platform_spec.rb index 49a26a16..2ddcc4cd 100644 --- a/spec/unit/plugins/freebsd/platform_spec.rb +++ b/spec/unit/plugins/freebsd/platform_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "FreeBSD plugin platform" do before(:each) do diff --git a/spec/unit/plugins/gce_spec.rb b/spec/unit/plugins/gce_spec.rb index 524aa760..4e1d4927 100644 --- a/spec/unit/plugins/gce_spec.rb +++ b/spec/unit/plugins/gce_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require 'open-uri' +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require "open-uri" describe Ohai::System, "plugin gce" do before(:each) do @@ -34,7 +34,7 @@ describe Ohai::System, "plugin gce" do before(:each) do @http_client = double("Net::HTTP client") allow(@plugin).to receive(:http_client).and_return(@http_client) - allow(IO).to receive(:select).and_return([[],[1],[]]) + allow(IO).to receive(:select).and_return([[], [1], []]) t = double("connection") allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS) allow(Socket).to receive(:new).and_return(t) @@ -44,12 +44,12 @@ describe Ohai::System, "plugin gce" do it "should recursively fetch and properly parse json metadata" do expect(@http_client).to receive(:get). with("/computeMetadata/v1beta1/?recursive=true/"). - and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code=>"200")) + and_return(double("Net::HTTP Response", :body => '{"instance":{"hostname":"test-host"}}', :code => "200")) @plugin.run expect(@plugin[:gce]).not_to be_nil - expect(@plugin[:gce]['instance']).to eq("hostname"=>"test-host") + expect(@plugin[:gce]["instance"]).to eq("hostname" => "test-host") end end @@ -58,10 +58,10 @@ describe Ohai::System, "plugin gce" do it_should_behave_like "gce" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/gce.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/gce.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/gce.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/gce.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/gce.json').and_return("") end end @@ -69,7 +69,7 @@ describe Ohai::System, "plugin gce" do it_should_behave_like "!gce" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/gce.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/gce.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/gce.json').and_return(false) # Raise Errno::ENOENT to simulate the scenario in which metadata server diff --git a/spec/unit/plugins/go_spec.rb b/spec/unit/plugins/go_spec.rb index cdfbb914..6f1f8809 100644 --- a/spec/unit/plugins/go_spec.rb +++ b/spec/unit/plugins/go_spec.rb @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin go" do diff --git a/spec/unit/plugins/groovy_spec.rb b/spec/unit/plugins/groovy_spec.rb index cfd42e55..bbd16c5c 100644 --- a/spec/unit/plugins/groovy_spec.rb +++ b/spec/unit/plugins/groovy_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin groovy" do diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb index b7a1c045..e0f7672d 100644 --- a/spec/unit/plugins/hostname_spec.rb +++ b/spec/unit/plugins/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "hostname plugin" do before(:each) do diff --git a/spec/unit/plugins/init_package_spec.rb b/spec/unit/plugins/init_package_spec.rb index f7c4e1be..29532c1d 100644 --- a/spec/unit/plugins/init_package_spec.rb +++ b/spec/unit/plugins/init_package_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "Init package" do let(:plugin) { diff --git a/spec/unit/plugins/ip_scopes_spec.rb b/spec/unit/plugins/ip_scopes_spec.rb index 4024c302..b0b600d0 100644 --- a/spec/unit/plugins/ip_scopes_spec.rb +++ b/spec/unit/plugins/ip_scopes_spec.rb @@ -1,12 +1,12 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") begin - require 'ipaddr_extensions' + require "ipaddr_extensions" rescue LoadError end describe Ohai::System, "plugin ip_scopes" do - let(:plugin) { get_plugin('ip_scopes') } + let(:plugin) { get_plugin("ip_scopes") } let(:network) { Mash.new(:interfaces => interfaces) } let(:interfaces) { Hash[ interface1, { :addresses => addresses1, :type => interface1_type }, @@ -15,59 +15,59 @@ describe Ohai::System, "plugin ip_scopes" do let(:interface2) { :eth1 } let(:addresses1) { {} } let(:addresses2) { {} } - let(:interface1_type) { 'eth' } - let(:interface2_type) { 'eth' } + let(:interface1_type) { "eth" } + let(:interface2_type) { "eth" } before { plugin[:network] = network } if defined?(IPAddrExtensions) - context 'with ipaddr_extensions gem' do - let(:ip1) { '10.0.0.1' } - let(:ip2) { '1.2.3.4' } - let(:ip3) { 'fe80::8638:35ff:fe4e:dc74' } + context "with ipaddr_extensions gem" do + let(:ip1) { "10.0.0.1" } + let(:ip2) { "1.2.3.4" } + let(:ip3) { "fe80::8638:35ff:fe4e:dc74" } let(:addresses1) { Hash[ip1, {}] } let(:addresses2) { Hash[ip2, {}, ip3, {}] } it "adds ip_scope to each address's information hash" do plugin.run - expect(plugin[:network][:interfaces][:eth0][:addresses]['10.0.0.1'][:ip_scope]).to eq('RFC1918 PRIVATE') - expect(plugin[:network][:interfaces][:eth1][:addresses]['1.2.3.4'][:ip_scope]).to eq('GLOBAL UNICAST') - expect(plugin[:network][:interfaces][:eth1][:addresses]['fe80::8638:35ff:fe4e:dc74'][:ip_scope]).to eq('LINK LOCAL UNICAST') + expect(plugin[:network][:interfaces][:eth0][:addresses]["10.0.0.1"][:ip_scope]).to eq("RFC1918 PRIVATE") + expect(plugin[:network][:interfaces][:eth1][:addresses]["1.2.3.4"][:ip_scope]).to eq("GLOBAL UNICAST") + expect(plugin[:network][:interfaces][:eth1][:addresses]["fe80::8638:35ff:fe4e:dc74"][:ip_scope]).to eq("LINK LOCAL UNICAST") end - describe 'privateaddress attribute' do + describe "privateaddress attribute" do before { plugin.run } - context 'when host has multiple RFC1918 ethernet addresses' do - let(:ip1) { '10.0.0.1' } - let(:ip2) { '192.168.1.1' } - let(:interface1_type) { 'eth' } - let(:interface2_type) { 'eth' } + context "when host has multiple RFC1918 ethernet addresses" do + let(:ip1) { "10.0.0.1" } + let(:ip2) { "192.168.1.1" } + let(:interface1_type) { "eth" } + let(:interface2_type) { "eth" } - it 'picks the last RFC1918 address' do - expect(plugin[:privateaddress]).to eq('192.168.1.1') + it "picks the last RFC1918 address" do + expect(plugin[:privateaddress]).to eq("192.168.1.1") end end - context 'when host has virtual and ethernet RFC1918 addresses' do - let(:ip1) { '10.0.0.1' } - let(:ip2) { '192.168.1.1' } - let(:interface1_type) { 'eth' } - let(:interface2_type) { 'ppp' } + context "when host has virtual and ethernet RFC1918 addresses" do + let(:ip1) { "10.0.0.1" } + let(:ip2) { "192.168.1.1" } + let(:interface1_type) { "eth" } + let(:interface2_type) { "ppp" } - it 'picks the non-virtual address' do - expect(plugin[:privateaddress]).to eq('10.0.0.1') + it "picks the non-virtual address" do + expect(plugin[:privateaddress]).to eq("10.0.0.1") end end - context 'when host only has virtual RFC1918 addresses' do - let(:ip1) { '10.0.0.1' } - let(:ip2) { '192.168.1.1' } - let(:interface1_type) { 'ppp' } - let(:interface2_type) { 'ppp' } + context "when host only has virtual RFC1918 addresses" do + let(:ip1) { "10.0.0.1" } + let(:ip2) { "192.168.1.1" } + let(:interface1_type) { "ppp" } + let(:interface2_type) { "ppp" } - it 'ignores them' do + it "ignores them" do expect(plugin[:privateaddress]).to be nil end end @@ -76,8 +76,8 @@ describe Ohai::System, "plugin ip_scopes" do end unless defined?(IPAddrExtensions) - context 'without the ipaddr_extensions gem' do - let(:addresses1) { Hash['10.0.0.1', {}] } + context "without the ipaddr_extensions gem" do + let(:addresses1) { Hash["10.0.0.1", {}] } before do # standin for raising on `require 'ipaddr_extensions'` @@ -85,11 +85,11 @@ describe Ohai::System, "plugin ip_scopes" do plugin.run end - it 'does not add ip_scope to addresses' do - expect(plugin[:network][:interfaces][:eth0][:addresses]['10.0.0.1'][:ip_scope]).to be nil + it "does not add ip_scope to addresses" do + expect(plugin[:network][:interfaces][:eth0][:addresses]["10.0.0.1"][:ip_scope]).to be nil end - it 'does not add a privateaddress attribute' do + it "does not add a privateaddress attribute" do expect(plugin[:privateaddress]).to be nil end end diff --git a/spec/unit/plugins/java_spec.rb b/spec/unit/plugins/java_spec.rb index c870ccba..bf5c7596 100644 --- a/spec/unit/plugins/java_spec.rb +++ b/spec/unit/plugins/java_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin java (Java5 Client VM)" do before(:each) do @@ -113,7 +113,7 @@ describe Ohai::System, "plugin java (Java5 Client VM)" do expect(@plugin[:languages]).not_to have_key(:java) end end - + shared_examples_for "when the openjdk 1.8 is installed" do before(:each) do diff --git a/spec/unit/plugins/joyent_spec.rb b/spec/unit/plugins/joyent_spec.rb index eb4a36df..a6670126 100644 --- a/spec/unit/plugins/joyent_spec.rb +++ b/spec/unit/plugins/joyent_spec.rb @@ -1,9 +1,8 @@ -require 'spec_helper' - +require "spec_helper" describe Ohai::System, "plugin joyent" do before(:each) do - @plugin = get_plugin('joyent') + @plugin = get_plugin("joyent") end describe "without joyent" do @@ -35,7 +34,7 @@ describe Ohai::System, "plugin joyent" do end it "should ditect global zone" do - expect(@plugin[:joyent][:sm_uuid]).to eql 'global' + expect(@plugin[:joyent][:sm_uuid]).to eql "global" end it "should NOT create sm_id" do @@ -45,19 +44,19 @@ describe Ohai::System, "plugin joyent" do describe "under smartmachine" do before(:each) do - @plugin[:virtualization][:guest_uuid] = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' - @plugin[:virtualization][:guest_id] = '30' + @plugin[:virtualization][:guest_uuid] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx" + @plugin[:virtualization][:guest_id] = "30" allow(@plugin).to receive(:collect_product_file).and_return(["Name: Joyent Instance", "Image: base64 13.4.2", "Documentation: http://wiki.joyent.com/jpc2/SmartMachine+Base"]) - allow(@plugin).to receive(:collect_pkgsrc).and_return('http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All') + allow(@plugin).to receive(:collect_pkgsrc).and_return("http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All") @plugin.run end it "should retrive zone uuid" do - expect(@plugin[:joyent][:sm_uuid]).to eql 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' + expect(@plugin[:joyent][:sm_uuid]).to eql "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx" end it "should collect sm_id" do - expect(@plugin[:joyent][:sm_id]).to eql '30' + expect(@plugin[:joyent][:sm_id]).to eql "30" end it "should collect images" do @@ -66,9 +65,8 @@ describe Ohai::System, "plugin joyent" do end it "should collect pkgsrc" do - expect(@plugin[:joyent][:sm_pkgsrc]).to eql 'http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All' + expect(@plugin[:joyent][:sm_pkgsrc]).to eql "http://pkgsrc.joyent.com/packages/SmartOS/2013Q4/x86_64/All" end end end end - diff --git a/spec/unit/plugins/kernel_spec.rb b/spec/unit/plugins/kernel_spec.rb index 30539740..c46952e5 100644 --- a/spec/unit/plugins/kernel_spec.rb +++ b/spec/unit/plugins/kernel_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin kernel" do before(:each) do @@ -39,7 +38,7 @@ describe Ohai::System, "plugin kernel" do describe "when running on windows", :windows_only do before do - require 'wmi-lite/wmi' + require "wmi-lite/wmi" @ohai_system = Ohai::System.new @plugin = get_plugin("kernel", @ohai_system) @@ -52,30 +51,30 @@ describe Ohai::System, "plugin kernel" do os_type = double("WIN32OLE", :name => "OsType") os_properties = [ caption, version, build_number, csd_version, os_type ] - os = double( "WIN32OLE", + os = double( "WIN32OLE", :properties_ => os_properties) - allow(os).to receive(:invoke).with(build_number.name).and_return('7601') - allow(os).to receive(:invoke).with(csd_version.name).and_return('Service Pack 1') + allow(os).to receive(:invoke).with(build_number.name).and_return("7601") + allow(os).to receive(:invoke).with(csd_version.name).and_return("Service Pack 1") allow(os).to receive(:invoke).with(os_type.name).and_return(18) - allow(os).to receive(:invoke).with(caption.name).and_return('Microsoft Windows 7 Ultimate') - allow(os).to receive(:invoke).with(version.name).and_return('6.1.7601') + allow(os).to receive(:invoke).with(caption.name).and_return("Microsoft Windows 7 Ultimate") + allow(os).to receive(:invoke).with(version.name).and_return("6.1.7601") os_wmi = WmiLite::Wmi::Instance.new(os) - expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with('Win32_OperatingSystem').and_return(os_wmi) + expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(os_wmi) # Mock a Win32_ComputerSystem OLE32 WMI object - x64_system_type = 'x64-based PC' + x64_system_type = "x64-based PC" cs = double("WIN32OLE", :properties_ => [ double("WIN32OLE", :name => "SystemType") ]) - allow(cs).to receive(:invoke).with('SystemType').and_return(x64_system_type) + allow(cs).to receive(:invoke).with("SystemType").and_return(x64_system_type) cs_wmi = WmiLite::Wmi::Instance.new(cs) - expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with('Win32_ComputerSystem').and_return(cs_wmi) + expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_ComputerSystem").and_return(cs_wmi) @plugin.run end diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb index 8da577a2..d0e918a1 100644 --- a/spec/unit/plugins/linode_spec.rb +++ b/spec/unit/plugins/linode_spec.rb @@ -15,38 +15,38 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin linode" do - let(:hint_path_nix) { '/etc/chef/ohai/hints/linode.json' } + let(:hint_path_nix) { "/etc/chef/ohai/hints/linode.json" } let(:hint_path_win) { 'C:\chef\ohai\hints/linode.json' } before do @plugin = get_plugin("linode") @plugin[:network] = { - "interfaces"=> { - "eth0"=> { - "addresses"=> { - "1.2.3.4"=> { - "broadcast"=> "67.23.20.255", - "netmask"=> "255.255.255.0", - "family"=> "inet" + "interfaces" => { + "eth0" => { + "addresses" => { + "1.2.3.4" => { + "broadcast" => "67.23.20.255", + "netmask" => "255.255.255.0", + "family" => "inet", }, - "fe80::4240:95ff:fe47:6eed"=> { - "scope"=> "Link", - "prefixlen"=> "64", - "family"=> "inet6" + "fe80::4240:95ff:fe47:6eed" => { + "scope" => "Link", + "prefixlen" => "64", + "family" => "inet6", }, "40:40:95:47:6E:ED" => { "family" => "lladdr" - } + }, } } } } end - shared_examples_for "!linode" do + shared_examples_for "!linode" do it "does not create the linode mash" do @plugin.run expect(@plugin[:linode]).to be_nil @@ -92,19 +92,19 @@ describe Ohai::System, "plugin linode" do before do @plugin[:network][:interfaces]["eth0:1"] = { "addresses" => { - "5.6.7.8"=> { - "broadcast"=> "10.176.191.255", - "netmask"=> "255.255.224.0", - "family"=> "inet" + "5.6.7.8" => { + "broadcast" => "10.176.191.255", + "netmask" => "255.255.224.0", + "family" => "inet", }, "fe80::4240:f5ff:feab:2836" => { - "scope"=> "Link", - "prefixlen"=> "64", - "family"=> "inet6" + "scope" => "Link", + "prefixlen" => "64", + "family" => "inet6", }, "40:40:F5:AB:28:36" => { - "family"=> "lladdr" - } + "family" => "lladdr" + }, } } end @@ -121,9 +121,9 @@ describe Ohai::System, "plugin linode" do describe "with linode cloud file" do before do allow(File).to receive(:exist?).with(hint_path_nix).and_return(true) - allow(File).to receive(:read).with(hint_path_nix).and_return('') + allow(File).to receive(:read).with(hint_path_nix).and_return("") allow(File).to receive(:exist?).with(hint_path_win).and_return(true) - allow(File).to receive(:read).with(hint_path_win).and_return('') + allow(File).to receive(:read).with(hint_path_win).and_return("") end it_should_behave_like "linode" @@ -139,7 +139,7 @@ describe Ohai::System, "plugin linode" do end context "with ec2 cloud file" do - let(:ec2_hint_path_nix) { '/etc/chef/ohai/hints/ec2.json' } + let(:ec2_hint_path_nix) { "/etc/chef/ohai/hints/ec2.json" } let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' } before do @@ -147,9 +147,9 @@ describe Ohai::System, "plugin linode" do allow(File).to receive(:exist?).with(hint_path_win).and_return(false) allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true) - allow(File).to receive(:read).with(ec2_hint_path_nix).and_return('') + allow(File).to receive(:read).with(ec2_hint_path_nix).and_return("") allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true) - allow(File).to receive(:read).with(ec2_hint_path_win).and_return('') + allow(File).to receive(:read).with(ec2_hint_path_win).and_return("") end it_should_behave_like "!linode" diff --git a/spec/unit/plugins/linux/block_device_spec.rb b/spec/unit/plugins/linux/block_device_spec.rb index 4fb9449a..edb4b243 100644 --- a/spec/unit/plugins/linux/block_device_spec.rb +++ b/spec/unit/plugins/linux/block_device_spec.rb @@ -15,24 +15,24 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") -describe Ohai::System, 'Linux Block Device Plugin' do +describe Ohai::System, "Linux Block Device Plugin" do DISKS = { - 'sda' => { - 'size' => '7814037168', - 'removable' => '0', - 'model' => 'WDC WD4000F9YZ-0', - 'rev' => '1A01', - 'state' => 'running', - 'timeout' => '30', - 'queue_depth' => '1', - 'vendor' => 'ATA' + "sda" => { + "size" => "7814037168", + "removable" => "0", + "model" => "WDC WD4000F9YZ-0", + "rev" => "1A01", + "state" => "running", + "timeout" => "30", + "queue_depth" => "1", + "vendor" => "ATA", + }, + "dm-0" => { + "size" => "7806976", + "removable" => "0", }, - 'dm-0' => { - 'size' => '7806976', - 'removable' => '0' - } } def file_double(value) @@ -42,11 +42,11 @@ describe Ohai::System, 'Linux Block Device Plugin' do end before(:each) do - @plugin = get_plugin('linux/block_device') + @plugin = get_plugin("linux/block_device") allow(@plugin).to receive(:collect_os).and_return(:linux) - allow(File).to receive(:exists?).with('/sys/block').and_return(true) - allow(Dir).to receive(:[]).with('/sys/block/*') do + allow(File).to receive(:exists?).with("/sys/block").and_return(true) + allow(Dir).to receive(:[]).with("/sys/block/*") do DISKS.collect { |disk, _files| "/sys/block/#{disk}" } end @@ -56,17 +56,17 @@ describe Ohai::System, 'Linux Block Device Plugin' do end allow(File).to receive(:exists?).with(Regexp.new(disk)) do |arg| - filepath = arg.split('/') + filepath = arg.split("/") checks[filepath.last].nil? ? false : true end allow(File).to receive(:basename) do |arg| - arg.split('/').last + arg.split("/").last end end end - it 'should collect all relevant data from disks' do + it "should collect all relevant data from disks" do @plugin.run DISKS.each do |disk, checks| expect(@plugin[:block_device][disk.to_sym]).to include(checks) diff --git a/spec/unit/plugins/linux/cpu_spec.rb b/spec/unit/plugins/linux/cpu_spec.rb index c3bf2f6a..f6252453 100644 --- a/spec/unit/plugins/linux/cpu_spec.rb +++ b/spec/unit/plugins/linux/cpu_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'tempfile' +require "tempfile" -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") shared_examples "Common cpu info" do |total_cpu, real_cpu| describe "cpu" do @@ -89,7 +89,7 @@ clflush size : 32 end let(:tempfile_handle) do - tempfile = Tempfile.new('ohai-rspec-proc-cpuinfo') + tempfile = Tempfile.new("ohai-rspec-proc-cpuinfo") tempfile.write cpuinfo_contents tempfile.rewind tempfile diff --git a/spec/unit/plugins/linux/filesystem2_spec.rb b/spec/unit/plugins/linux/filesystem2_spec.rb index cd10ec97..e62e9d1a 100644 --- a/spec/unit/plugins/linux/filesystem2_spec.rb +++ b/spec/unit/plugins/linux/filesystem2_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux filesystem plugin" do let (:plugin) { get_plugin("linux/filesystem2") } @@ -166,7 +166,7 @@ MOUNT it "should set mount_options to an array of values from mount" do plugin.run - expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime" ]) + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime}) end end @@ -338,7 +338,7 @@ MOUNTS it "should set mount_options to an array of values from /proc/mounts" do plugin.run - expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) + expect(plugin[:filesystem2]["by_pair"]["/dev/mapper/sys.vg-special.lv,/special"][:mount_options]).to eq(%w{ro noatime attr2 noquota}) end end @@ -385,9 +385,9 @@ BLKID_TYPE it "should provide a devices view with all mountpoints" do plugin.run - expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(['/', '/var/chroot']) - expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(['/home', '/home2']) - expect(plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(['/lib/init/rw', '/dev/shm']) + expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-root.lv"][:mounts]).to eq(["/", "/var/chroot"]) + expect(plugin[:filesystem2]["by_device"]["/dev/mapper/sys.vg-home.lv"][:mounts]).to eq(["/home", "/home2"]) + expect(plugin[:filesystem2]["by_device"]["tmpfs"][:mounts]).to eq(["/lib/init/rw", "/dev/shm"]) end end @@ -431,7 +431,7 @@ BLKID_TYPE it "should provide a mounts view with all devices" do plugin.run - expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(['/dev/sdb1', '/dev/sdc1']) + expect(plugin[:filesystem2]["by_mountpoint"]["/mnt"][:devices]).to eq(["/dev/sdb1", "/dev/sdc1"]) end end end diff --git a/spec/unit/plugins/linux/filesystem_spec.rb b/spec/unit/plugins/linux/filesystem_spec.rb index e1c1b354..7375a8cf 100644 --- a/spec/unit/plugins/linux/filesystem_spec.rb +++ b/spec/unit/plugins/linux/filesystem_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux filesystem plugin" do let(:plugin) { get_plugin("linux/filesystem") } @@ -73,7 +73,7 @@ tmpfs 2030944 2960 2027984 1% /dev/shm /dev/md0 960492 36388 875312 4% /boot DF allow(plugin).to receive(:shell_out).with("df -P").and_return(mock_shell_out(0, @stdout, "")) - + @inode_stdout = <<-DFi Filesystem Inodes IUsed IFree IUse% Mounted on /dev/xvda1 1310720 107407 1203313 9% / @@ -115,17 +115,17 @@ DFi plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end - + it "should set total_inodes to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:total_inodes]).to eq("124865") end - + it "should set inodes_used to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_used]).to eq("380") end - + it "should set inodes_available to value from df -iP" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:inodes_available]).to eq("124485") @@ -171,26 +171,26 @@ MOUNT it "should set mount_options to an array of values from mount" do plugin.run - expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime" ]) + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime}) end end describe "when gathering filesystem type data from blkid" do before(:each) do @stdout = <<-BLKID_TYPE -/dev/sdb1: TYPE=\"linux_raid_member\" -/dev/sdb2: TYPE=\"linux_raid_member\" -/dev/sda1: TYPE=\"linux_raid_member\" -/dev/sda2: TYPE=\"linux_raid_member\" -/dev/md0: TYPE=\"ext3\" -/dev/md1: TYPE=\"LVM2_member\" -/dev/mapper/sys.vg-root.lv: TYPE=\"ext4\" -/dev/mapper/sys.vg-swap.lv: TYPE=\"swap\" -/dev/mapper/sys.vg-tmp.lv: TYPE=\"ext4\" -/dev/mapper/sys.vg-usr.lv: TYPE=\"ext4\" -/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\" -/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\" -/dev/mapper/debian--7-root: TYPE=\"ext4\" +/dev/sdb1: TYPE=\"linux_raid_member\" +/dev/sdb2: TYPE=\"linux_raid_member\" +/dev/sda1: TYPE=\"linux_raid_member\" +/dev/sda2: TYPE=\"linux_raid_member\" +/dev/md0: TYPE=\"ext3\" +/dev/md1: TYPE=\"LVM2_member\" +/dev/mapper/sys.vg-root.lv: TYPE=\"ext4\" +/dev/mapper/sys.vg-swap.lv: TYPE=\"swap\" +/dev/mapper/sys.vg-tmp.lv: TYPE=\"ext4\" +/dev/mapper/sys.vg-usr.lv: TYPE=\"ext4\" +/dev/mapper/sys.vg-var.lv: TYPE=\"ext4\" +/dev/mapper/sys.vg-home.lv: TYPE=\"xfs\" +/dev/mapper/debian--7-root: TYPE=\"ext4\" BLKID_TYPE allow(plugin).to receive(:shell_out).with("blkid -s TYPE").and_return(mock_shell_out(0, @stdout, "")) end @@ -210,19 +210,19 @@ BLKID_TYPE before(:each) do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_TYPE -NAME="sdb1" FSTYPE="linux_raid_member" -NAME="sdb2" FSTYPE="linux_raid_member" -NAME="sda1" FSTYPE="linux_raid_member" -NAME="sda2" FSTYPE="linux_raid_member" -NAME="md0" FSTYPE="ext3" -NAME="md1" FSTYPE="LVM2_member" -NAME="sys.vg-root.lv" FSTYPE="ext4" -NAME="sys.vg-swap.lv" FSTYPE="swap" -NAME="sys.vg-tmp.lv" FSTYPE="ext4" -NAME="sys.vg-usr.lv" FSTYPE="ext4" -NAME="sys.vg-var.lv" FSTYPE="ext4" -NAME="sys.vg-home.lv" FSTYPE="xfs" -NAME="debian--7-root (dm-0)" FSTYPE="ext4" +NAME="sdb1" FSTYPE="linux_raid_member" +NAME="sdb2" FSTYPE="linux_raid_member" +NAME="sda1" FSTYPE="linux_raid_member" +NAME="sda2" FSTYPE="linux_raid_member" +NAME="md0" FSTYPE="ext3" +NAME="md1" FSTYPE="LVM2_member" +NAME="sys.vg-root.lv" FSTYPE="ext4" +NAME="sys.vg-swap.lv" FSTYPE="swap" +NAME="sys.vg-tmp.lv" FSTYPE="ext4" +NAME="sys.vg-usr.lv" FSTYPE="ext4" +NAME="sys.vg-var.lv" FSTYPE="ext4" +NAME="sys.vg-home.lv" FSTYPE="xfs" +NAME="debian--7-root (dm-0)" FSTYPE="ext4" BLKID_TYPE allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,FSTYPE"). and_return(mock_shell_out(0, @stdout, "")) @@ -248,19 +248,19 @@ BLKID_TYPE describe "when gathering filesystem uuid data from blkid" do before(:each) do @stdout = <<-BLKID_UUID -/dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" -/dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" -/dev/sda1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" -/dev/sda2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" -/dev/md0: UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" -/dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" -/dev/mapper/sys.vg-root.lv: UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" -/dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" -/dev/mapper/sys.vg-tmp.lv: UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" -/dev/mapper/sys.vg-usr.lv: UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" -/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" -/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" -/dev/mapper/debian--7-root: UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" +/dev/sdb1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" +/dev/sdb2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" +/dev/sda1: UUID=\"bd1197e0-6997-1f3a-e27e-7801388308b5\" +/dev/sda2: UUID=\"e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa\" +/dev/md0: UUID=\"37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32\" +/dev/md1: UUID=\"YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK\" +/dev/mapper/sys.vg-root.lv: UUID=\"7742d14b-80a3-4e97-9a32-478be9ea9aea\" +/dev/mapper/sys.vg-swap.lv: UUID=\"9bc2e515-8ddc-41c3-9f63-4eaebde9ce96\" +/dev/mapper/sys.vg-tmp.lv: UUID=\"74cf7eb9-428f-479e-9a4a-9943401e81e5\" +/dev/mapper/sys.vg-usr.lv: UUID=\"26ec33c5-d00b-4f88-a550-492def013bbc\" +/dev/mapper/sys.vg-var.lv: UUID=\"6b559c35-7847-4ae2-b512-c99012d3f5b3\" +/dev/mapper/sys.vg-home.lv: UUID=\"d6efda02-1b73-453c-8c74-7d8dee78fa5e\" +/dev/mapper/debian--7-root: UUID=\"09187faa-3512-4505-81af-7e86d2ccb99a\" BLKID_UUID allow(plugin).to receive(:shell_out).with("blkid -s UUID").and_return(mock_shell_out(0, @stdout, "")) end @@ -280,19 +280,19 @@ BLKID_UUID before(:each) do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_UUID -NAME="sdb1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5" -NAME="sdb2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" -NAME="sda1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5" -NAME="sda2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" -NAME="md0" UUID="37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32" -NAME="md1" UUID="YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK" -NAME="sys.vg-root.lv" UUID="7742d14b-80a3-4e97-9a32-478be9ea9aea" -NAME="sys.vg-swap.lv" UUID="9bc2e515-8ddc-41c3-9f63-4eaebde9ce96" -NAME="sys.vg-tmp.lv" UUID="74cf7eb9-428f-479e-9a4a-9943401e81e5" -NAME="sys.vg-usr.lv" UUID="26ec33c5-d00b-4f88-a550-492def013bbc" -NAME="sys.vg-var.lv" UUID="6b559c35-7847-4ae2-b512-c99012d3f5b3" -NAME="sys.vg-home.lv" UUID="d6efda02-1b73-453c-8c74-7d8dee78fa5e" -NAME="debian--7-root (dm-0)" UUID="09187faa-3512-4505-81af-7e86d2ccb99a" +NAME="sdb1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5" +NAME="sdb2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" +NAME="sda1" UUID="bd1197e0-6997-1f3a-e27e-7801388308b5" +NAME="sda2" UUID="e36d933e-e5b9-cfe5-6845-1f84d0f7fbfa" +NAME="md0" UUID="37b8de8e-0fe3-4b5a-b9b4-dde33e19bb32" +NAME="md1" UUID="YsIe0R-fj1y-LXTd-imla-opKo-OuIe-TBoxSK" +NAME="sys.vg-root.lv" UUID="7742d14b-80a3-4e97-9a32-478be9ea9aea" +NAME="sys.vg-swap.lv" UUID="9bc2e515-8ddc-41c3-9f63-4eaebde9ce96" +NAME="sys.vg-tmp.lv" UUID="74cf7eb9-428f-479e-9a4a-9943401e81e5" +NAME="sys.vg-usr.lv" UUID="26ec33c5-d00b-4f88-a550-492def013bbc" +NAME="sys.vg-var.lv" UUID="6b559c35-7847-4ae2-b512-c99012d3f5b3" +NAME="sys.vg-home.lv" UUID="d6efda02-1b73-453c-8c74-7d8dee78fa5e" +NAME="debian--7-root (dm-0)" UUID="09187faa-3512-4505-81af-7e86d2ccb99a" BLKID_UUID allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,UUID"). and_return(mock_shell_out(0, @stdout, "")) @@ -322,17 +322,17 @@ BLKID_UUID describe "when gathering filesystem label data from blkid" do before(:each) do @stdout = <<-BLKID_LABEL -/dev/sda1: LABEL=\"fuego:0\" -/dev/sda2: LABEL=\"fuego:1\" -/dev/sdb1: LABEL=\"fuego:0\" -/dev/sdb2: LABEL=\"fuego:1\" -/dev/md0: LABEL=\"/boot\" -/dev/mapper/sys.vg-root.lv: LABEL=\"/\" -/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" -/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" -/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" -/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" -/dev/mapper/debian--7-root: LABEL=\"root\" +/dev/sda1: LABEL=\"fuego:0\" +/dev/sda2: LABEL=\"fuego:1\" +/dev/sdb1: LABEL=\"fuego:0\" +/dev/sdb2: LABEL=\"fuego:1\" +/dev/md0: LABEL=\"/boot\" +/dev/mapper/sys.vg-root.lv: LABEL=\"/\" +/dev/mapper/sys.vg-tmp.lv: LABEL=\"/tmp\" +/dev/mapper/sys.vg-usr.lv: LABEL=\"/usr\" +/dev/mapper/sys.vg-var.lv: LABEL=\"/var\" +/dev/mapper/sys.vg-home.lv: LABEL=\"/home\" +/dev/mapper/debian--7-root: LABEL=\"root\" BLKID_LABEL allow(plugin).to receive(:shell_out).with("blkid -s LABEL").and_return(mock_shell_out(0, @stdout, "")) end @@ -352,17 +352,17 @@ BLKID_LABEL before(:each) do allow(File).to receive(:exist?).with("/bin/lsblk").and_return(true) @stdout = <<-BLKID_LABEL -NAME="sda1" LABEL="fuego:0" -NAME="sda2" LABEL="fuego:1" -NAME="sdb1" LABEL="fuego:0" -NAME="sdb2" LABEL="fuego:1" -NAME="md0" LABEL="/boot" -NAME="sys.vg-root.lv" LABEL="/" -NAME="sys.vg-tmp.lv" LABEL="/tmp" -NAME="sys.vg-usr.lv" LABEL="/usr" -NAME="sys.vg-var.lv" LABEL="/var" -NAME="sys.vg-home.lv" LABEL="/home" -NAME="debian--7-root (dm-0)" LABEL="root" +NAME="sda1" LABEL="fuego:0" +NAME="sda2" LABEL="fuego:1" +NAME="sdb1" LABEL="fuego:0" +NAME="sdb2" LABEL="fuego:1" +NAME="md0" LABEL="/boot" +NAME="sys.vg-root.lv" LABEL="/" +NAME="sys.vg-tmp.lv" LABEL="/tmp" +NAME="sys.vg-usr.lv" LABEL="/usr" +NAME="sys.vg-var.lv" LABEL="/var" +NAME="sys.vg-home.lv" LABEL="/home" +NAME="debian--7-root (dm-0)" LABEL="root" BLKID_LABEL allow(plugin).to receive(:shell_out).with("lsblk -P -n -o NAME,LABEL"). and_return(mock_shell_out(0, @stdout, "")) @@ -385,7 +385,6 @@ BLKID_LABEL end end - describe "when gathering data from /proc/mounts" do before(:each) do allow(File).to receive(:exist?).with("/proc/mounts").and_return(true) @@ -422,15 +421,15 @@ MOUNTS plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount]).to eq("/special") end - + it "should set fs_type to value from /proc/mounts" do plugin.run expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:fs_type]).to eq("xfs") end - + it "should set mount_options to an array of values from /proc/mounts" do plugin.run - expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq([ "ro", "noatime", "attr2", "noquota" ]) + expect(plugin[:filesystem]["/dev/mapper/sys.vg-special.lv"][:mount_options]).to eq(%w{ro noatime attr2 noquota}) end end diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb index f6eb5ffb..a7dba293 100644 --- a/spec/unit/plugins/linux/hostname_spec.rb +++ b/spec/unit/plugins/linux/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux hostname plugin" do before(:each) do @@ -51,4 +50,3 @@ describe Ohai::System, "Linux hostname plugin" do end end - diff --git a/spec/unit/plugins/linux/kernel_spec.rb b/spec/unit/plugins/linux/kernel_spec.rb index 0f964a3e..75313114 100644 --- a/spec/unit/plugins/linux/kernel_spec.rb +++ b/spec/unit/plugins/linux/kernel_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux kernel plugin" do before(:each) do diff --git a/spec/unit/plugins/linux/lsb_spec.rb b/spec/unit/plugins/linux/lsb_spec.rb index 162b4786..eac26412 100644 --- a/spec/unit/plugins/linux/lsb_spec.rb +++ b/spec/unit/plugins/linux/lsb_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") # We do not alter case for lsb attributes and consume them as provided diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb index 48ddd92f..2e8b533d 100644 --- a/spec/unit/plugins/linux/mdadm_spec.rb +++ b/spec/unit/plugins/linux/mdadm_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux Mdadm Plugin" do before(:each) do @@ -57,9 +57,9 @@ MD allow(@plugin).to receive(:collect_os).and_return(:linux) @double_file = double("/proc/mdstat") allow(@double_file).to receive(:each). - and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]"). - and_yield("md0 : active raid10 sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]"). - and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]") + and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]"). + and_yield("md0 : active raid10 sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]"). + and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]") allow(File).to receive(:open).with("/proc/mdstat").and_return(@double_file) allow(File).to receive(:exist?).with("/proc/mdstat").and_return(true) allow(@plugin).to receive(:shell_out).with("mdadm --detail /dev/md0").and_return(mock_shell_out(0, @md0, "")) diff --git a/spec/unit/plugins/linux/memory_spec.rb b/spec/unit/plugins/linux/memory_spec.rb index cb2fe1b8..fd5bfc39 100644 --- a/spec/unit/plugins/linux/memory_spec.rb +++ b/spec/unit/plugins/linux/memory_spec.rb @@ -14,7 +14,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux memory plugin" do before(:each) do @@ -61,144 +61,140 @@ describe Ohai::System, "Linux memory plugin" do @plugin.run expect(@plugin[:memory][:total]).to eql("131932120kB") end - + it "should get free memory" do @plugin.run expect(@plugin[:memory][:free]).to eql("2269032kB") end - + it "should get memory used for file buffers" do @plugin.run expect(@plugin[:memory][:buffers]).to eql("646368kB") end - + it "should get cache memory" do @plugin.run expect(@plugin[:memory][:cached]).to eql("32346556kB") end - + it "should get active memory" do @plugin.run expect(@plugin[:memory][:active]).to eql("98595796kB") end - + it "should get inactive memory" do @plugin.run expect(@plugin[:memory][:inactive]).to eql("18477320kB") end - + it "should get high_total memory" do @plugin.run expect(@plugin[:memory][:high_total]).to eql("0kB") end - + it "should get high_free memory" do @plugin.run expect(@plugin[:memory][:high_free]).to eql("0kB") end - + it "should get low_total memory" do @plugin.run expect(@plugin[:memory][:low_total]).to eql("131932120kB") end - + it "should get low_free memory" do @plugin.run expect(@plugin[:memory][:low_free]).to eql("2269032kB") end - + it "should get dirty memory" do @plugin.run expect(@plugin[:memory][:dirty]).to eql("3212kB") end - + it "should get writeback memory" do @plugin.run expect(@plugin[:memory][:writeback]).to eql("0kB") end - + it "should get anon_pages memory" do @plugin.run expect(@plugin[:memory][:anon_pages]).to eql("84082132kB") end - + it "should get mapped memory" do @plugin.run expect(@plugin[:memory][:mapped]).to eql("3445224kB") end - - + it "should get slab memory" do @plugin.run expect(@plugin[:memory][:slab]).to eql("9892096kB") end - + it "should get slab_reclaimable memory" do @plugin.run expect(@plugin[:memory][:slab_reclaimable]).to eql("362636kB") end - + it "should get slab_reclaimable memory" do @plugin.run expect(@plugin[:memory][:slab_unreclaim]).to eql("18860kB") end - + it "should get page_tables memory" do @plugin.run expect(@plugin[:memory][:page_tables]).to eql("1759332kB") end - - + it "should get nfs_unstable memory" do @plugin.run expect(@plugin[:memory][:nfs_unstable]).to eql("0kB") end - + it "should get bounce memory" do @plugin.run expect(@plugin[:memory][:bounce]).to eql("0kB") end - + it "should get commit_limit memory" do @plugin.run expect(@plugin[:memory][:commit_limit]).to eql("148709328kB") end - + it "should get committed_as memory" do @plugin.run expect(@plugin[:memory][:committed_as]).to eql("333717060kB") end - + it "should get vmalloc_total memory" do @plugin.run expect(@plugin[:memory][:vmalloc_total]).to eql("34359738367kB") end - + it "should get vmalloc_used memory" do @plugin.run expect(@plugin[:memory][:vmalloc_used]).to eql("276796kB") end - + it "should get vmalloc_chunk memory" do @plugin.run expect(@plugin[:memory][:vmalloc_chunk]).to eql("34359461515kB") end - + it "should get total swap" do @plugin.run expect(@plugin[:memory][:swap][:total]).to eql("16777208kB") end - + it "should get cached swap" do @plugin.run expect(@plugin[:memory][:swap][:cached]).to eql("312kB") end - + it "should get free swap" do @plugin.run expect(@plugin[:memory][:swap][:free]).to eql("14127356kB") end - - - + end diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb index bae9af29..0e924169 100644 --- a/spec/unit/plugins/linux/platform_spec.rb +++ b/spec/unit/plugins/linux/platform_spec.rb @@ -16,9 +16,8 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux plugin platform" do @@ -203,9 +202,9 @@ describe Ohai::System, "Linux plugin platform" do end it "should set platform_version to kernel release" do - expect(@plugin).to receive(:`).with('uname -r').and_return('3.18.2-2-ARCH') + expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH") @plugin.run - expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH') + expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH") end end @@ -238,7 +237,7 @@ describe Ohai::System, "Linux plugin platform" do @plugin.run expect(@plugin[:platform]).to eq("alpine") expect(@plugin[:platform_family]).to eq("alpine") - expect(@plugin[:platform_version]).to eq('3.2.3') + expect(@plugin[:platform_version]).to eq("3.2.3") end end @@ -257,9 +256,9 @@ describe Ohai::System, "Linux plugin platform" do end it "should set platform_version to kernel release" do - expect(@plugin).to receive(:`).with('uname -r').and_return('3.18.2-2-ARCH') + expect(@plugin).to receive(:`).with("uname -r").and_return("3.18.2-2-ARCH") @plugin.run - expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH') + expect(@plugin[:platform_version]).to eq("3.18.2-2-ARCH") end end @@ -671,114 +670,114 @@ CISCO_RELEASE describe '#read_os_release_info' do let(:file_contents) { "COW=MOO\nDOG=\"BARK\"" } - it 'returns nil if the file does not exist' do - allow(File).to receive(:exist?).with('/etc/test-release').and_return(false) - expect(@plugin.read_os_release_info('/etc/test-release')).to be nil + it "returns nil if the file does not exist" do + allow(File).to receive(:exist?).with("/etc/test-release").and_return(false) + expect(@plugin.read_os_release_info("/etc/test-release")).to be nil end - it 'returns a hash of expected contents' do - allow(File).to receive(:exist?).with('/etc/test-release').and_return(true) - allow(File).to receive(:read).with('/etc/test-release').and_return(file_contents) - release_info = @plugin.read_os_release_info('/etc/test-release') + it "returns a hash of expected contents" do + allow(File).to receive(:exist?).with("/etc/test-release").and_return(true) + allow(File).to receive(:read).with("/etc/test-release").and_return(file_contents) + release_info = @plugin.read_os_release_info("/etc/test-release") - expect(release_info['COW']).to eq('MOO') - expect(release_info['DOG']).to eq('BARK') + expect(release_info["COW"]).to eq("MOO") + expect(release_info["DOG"]).to eq("BARK") end end describe '#os_release_info' do - context 'when CISCO_RELEASE_INFO is not populated' do - let(:release_info) { { 'ID' => 'os_id' } } + context "when CISCO_RELEASE_INFO is not populated" do + let(:release_info) { { "ID" => "os_id" } } before do - allow(File).to receive(:exist?).with('/etc/os-release').and_return(true) - allow(@plugin).to receive(:read_os_release_info).with('/etc/os-release').and_return(release_info) + allow(File).to receive(:exist?).with("/etc/os-release").and_return(true) + allow(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info) end - it 'reads the os-release file' do - expect(@plugin).to receive(:read_os_release_info).with('/etc/os-release').and_return(release_info) + it "reads the os-release file" do + expect(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info) @plugin.os_release_info end - it 'returns a hash of expected contents' do - expect(@plugin.os_release_info['ID']).to eq('os_id') + it "returns a hash of expected contents" do + expect(@plugin.os_release_info["ID"]).to eq("os_id") end end - context 'when CISCO_RELEASE_INFO is populated' do - let(:release_info) { { 'ID' => 'os_id', 'CISCO_RELEASE_INFO' => '/etc/cisco-release' } } - let(:cisco_release_info) { { 'ID' => 'cisco_id' } } + context "when CISCO_RELEASE_INFO is populated" do + let(:release_info) { { "ID" => "os_id", "CISCO_RELEASE_INFO" => "/etc/cisco-release" } } + let(:cisco_release_info) { { "ID" => "cisco_id" } } before do - allow(File).to receive(:exist?).with('/etc/os-release').and_return(true) - allow(File).to receive(:exist?).with('/etc/cisco-release').and_return(true) - allow(@plugin).to receive(:read_os_release_info).with('/etc/os-release').and_return(release_info) - allow(@plugin).to receive(:read_os_release_info).with('/etc/cisco-release').and_return(cisco_release_info) + allow(File).to receive(:exist?).with("/etc/os-release").and_return(true) + allow(File).to receive(:exist?).with("/etc/cisco-release").and_return(true) + allow(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info) + allow(@plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(cisco_release_info) end - it 'reads the os-release AND the cisco-release file' do - expect(@plugin).to receive(:read_os_release_info).with('/etc/os-release').and_return(release_info) - expect(@plugin).to receive(:read_os_release_info).with('/etc/cisco-release').and_return(release_info) + it "reads the os-release AND the cisco-release file" do + expect(@plugin).to receive(:read_os_release_info).with("/etc/os-release").and_return(release_info) + expect(@plugin).to receive(:read_os_release_info).with("/etc/cisco-release").and_return(release_info) @plugin.os_release_info end - it 'returns the ID from the cisco-release file instead of the os-release file' do - expect(@plugin.os_release_info['ID']).to eq('cisco_id') + it "returns the ID from the cisco-release file instead of the os-release file" do + expect(@plugin.os_release_info["ID"]).to eq("cisco_id") end end end - describe 'on Wind River Linux 5 for Cisco Nexus' do + describe "on Wind River Linux 5 for Cisco Nexus" do let(:have_os_release) { true } let(:os_release_info) do { - 'ID' => 'nexus', - 'ID_LIKE' => 'wrlinux', - 'NAME' => 'Nexus', - 'VERSION' => '7.0(3)I2(0.475E.6)', - 'VERSION_ID' => '7.0(3)I2', - 'PRETTY_NAME' => 'Nexus 7.0(3)I2', - 'HOME_URL' => 'http://www.cisco.com', - 'BUILD_ID' => '6', - 'CISCO_RELEASE_INFO' => '/etc/os-release' + "ID" => "nexus", + "ID_LIKE" => "wrlinux", + "NAME" => "Nexus", + "VERSION" => "7.0(3)I2(0.475E.6)", + "VERSION_ID" => "7.0(3)I2", + "PRETTY_NAME" => "Nexus 7.0(3)I2", + "HOME_URL" => "http://www.cisco.com", + "BUILD_ID" => "6", + "CISCO_RELEASE_INFO" => "/etc/os-release", } end - it 'should set platform to nexus and platform_family to wrlinux' do + it "should set platform to nexus and platform_family to wrlinux" do allow(@plugin).to receive(:os_release_info).and_return(os_release_info) @plugin.lsb = nil @plugin.run - expect(@plugin[:platform]).to eq('nexus') - expect(@plugin[:platform_family]).to eq('wrlinux') - expect(@plugin[:platform_version]).to eq('7.0(3)I2(0.475E.6)') + expect(@plugin[:platform]).to eq("nexus") + expect(@plugin[:platform_family]).to eq("wrlinux") + expect(@plugin[:platform_version]).to eq("7.0(3)I2(0.475E.6)") end end - describe 'on Wind River Linux 7 for Cisco IOS-XR' do + describe "on Wind River Linux 7 for Cisco IOS-XR" do let(:have_os_release) { true } let(:os_release_info) do { - 'ID' => 'ios_xr', - 'ID_LIKE' => 'cisco-wrlinux wrlinux', - 'NAME' => 'IOS XR', - 'VERSION' => '6.0.0.14I', - 'VERSION_ID' => '6.0.0.14I', - 'PRETTY_NAME' => 'Cisco IOS XR Software, Version 6.0.0.14I', - 'BUILD_ID' => '2015-09-10-15-50-17', - 'HOME_URL' => 'http://www.cisco.com', - 'CISCO_RELEASE_INFO' => '/etc/os-release' + "ID" => "ios_xr", + "ID_LIKE" => "cisco-wrlinux wrlinux", + "NAME" => "IOS XR", + "VERSION" => "6.0.0.14I", + "VERSION_ID" => "6.0.0.14I", + "PRETTY_NAME" => "Cisco IOS XR Software, Version 6.0.0.14I", + "BUILD_ID" => "2015-09-10-15-50-17", + "HOME_URL" => "http://www.cisco.com", + "CISCO_RELEASE_INFO" => "/etc/os-release", } end - it 'should set platform to ios_xr and platform_family to wrlinux' do + it "should set platform to ios_xr and platform_family to wrlinux" do allow(@plugin).to receive(:os_release_info).and_return(os_release_info) @plugin.lsb = nil @plugin.run - expect(@plugin[:platform]).to eq('ios_xr') - expect(@plugin[:platform_family]).to eq('wrlinux') - expect(@plugin[:platform_version]).to eq('6.0.0.14I') + expect(@plugin[:platform]).to eq("ios_xr") + expect(@plugin[:platform_family]).to eq("wrlinux") + expect(@plugin[:platform_version]).to eq("6.0.0.14I") end end end diff --git a/spec/unit/plugins/linux/uptime_spec.rb b/spec/unit/plugins/linux/uptime_spec.rb index 32cf110f..4bdc46de 100644 --- a/spec/unit/plugins/linux/uptime_spec.rb +++ b/spec/unit/plugins/linux/uptime_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux plugin uptime" do before(:each) do diff --git a/spec/unit/plugins/linux/virtualization_spec.rb b/spec/unit/plugins/linux/virtualization_spec.rb index 1ed15659..91afd507 100644 --- a/spec/unit/plugins/linux/virtualization_spec.rb +++ b/spec/unit/plugins/linux/virtualization_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Linux virtualization platform" do let(:plugin) { get_plugin("linux/virtualization") } @@ -72,7 +72,7 @@ describe Ohai::System, "Linux virtualization platform" do it "does not set virtualization if xen isn't there" do expect(File).to receive(:exist?).at_least(:once).and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -116,7 +116,7 @@ describe Ohai::System, "Linux virtualization platform" do it "does not set virtualization if kvm isn't there" do expect(File).to receive(:exist?).at_least(:once).and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -142,7 +142,7 @@ describe Ohai::System, "Linux virtualization platform" do it "does not set virtualization if vbox isn't there" do expect(File).to receive(:exist?).at_least(:once).and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -152,7 +152,7 @@ describe Ohai::System, "Linux virtualization platform" do end it "sets virtualpc guest if dmidecode detects Microsoft Virtual Machine" do - ms_vpc_dmidecode=<<-MSVPC + ms_vpc_dmidecode = <<-MSVPC System Information Manufacturer: Microsoft Corporation Product Name: Virtual Machine @@ -169,7 +169,7 @@ MSVPC end it "sets hyperv guest if dmidecode detects Hyper-V or version 7.0" do - ms_hv_dmidecode=<<-MSHV + ms_hv_dmidecode = <<-MSHV System Information Manufacturer: Microsoft Corporation Product Name: Virtual Machine @@ -186,7 +186,7 @@ MSHV end it "sets virtualserver guest if dmidecode detects version 5.0" do - ms_vs_dmidecode=<<-MSVS + ms_vs_dmidecode = <<-MSVS System Information Manufacturer: Microsoft Corporation Product Name: Virtual Machine @@ -203,7 +203,7 @@ MSVS end it "sets vmware guest if dmidecode detects VMware" do - vmware_dmidecode=<<-VMWARE + vmware_dmidecode = <<-VMWARE System Information Manufacturer: VMware, Inc. Product Name: VMware Virtual Platform @@ -222,7 +222,7 @@ VMWARE end it "sets vbox guest if dmidecode detects VirtualBox" do - vbox_dmidecode=<<-VBOX + vbox_dmidecode = <<-VBOX Base Board Information Manufacturer: Oracle Corporation Product Name: VirtualBox @@ -243,7 +243,7 @@ VBOX end it "sets openstack guest if dmidecode detects OpenStack" do - openstack_dmidecode=<<-OPENSTACK + openstack_dmidecode = <<-OPENSTACK System Information Manufacturer: Red Hat Inc. Product Name: OpenStack Nova @@ -262,7 +262,7 @@ OPENSTACK end it "sets kvm guest if dmidecode contains KVM" do - kvm_dmidecode=<<-RKVM + kvm_dmidecode = <<-RKVM System Information Manufacturer: Red Hat Product Name: KVM @@ -281,7 +281,7 @@ RKVM end it "sets kvm guest if dmidecode detects RHEV" do - kvm_dmidecode=<<-RHEV + kvm_dmidecode = <<-RHEV System Information Manufacturer: Red Hat Product Name: RHEV Hypervisor @@ -302,7 +302,7 @@ RHEV it "should run dmidecode and not set virtualization if nothing is detected" do allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", "")) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -313,7 +313,7 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("host") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("host") end it "sets Linux-VServer host if /proc/self/status contains VxID: 0" do @@ -322,7 +322,7 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("host") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("host") end it "sets Linux-VServer host if /proc/self/status contains multiple space VxID: 0" do @@ -331,7 +331,7 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("host") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("host") end it "sets Linux-VServer host if /proc/self/status contains tabbed VxID:\t0" do @@ -340,7 +340,7 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("host") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("host") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("host") end it "sets Linux-VServer guest if /proc/self/status contains s_context > 0" do @@ -349,7 +349,7 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("guest") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("guest") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("guest") end it "sets Linux-VServer guest if /proc/self/status contains VxID > 0" do @@ -358,13 +358,13 @@ RHEV plugin.run expect(plugin[:virtualization][:system]).to eq("linux-vserver") expect(plugin[:virtualization][:role]).to eq("guest") - expect(plugin[:virtualization][:systems]['linux-vserver']).to eq("guest") + expect(plugin[:virtualization][:systems]["linux-vserver"]).to eq("guest") end it "does not set virtualization if Linux-VServer isn't there" do expect(File).to receive(:exist?).at_least(:once).and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -390,13 +390,13 @@ RHEV expect(File).to receive(:exist?).with("/proc/bc/0").and_return(false) expect(File).to receive(:exist?).with("/proc/vz").and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end describe "when we are checking for parallels" do it "sets parallels guest if /proc/bus/pci/devices contains 1ab84000" do - devices=<<-DEVICES + devices = <<-DEVICES 0018 1ab84000 1f 8001 0 0 0 0 0 0 20 0 0 0 0 0 0 prl_tg 0028 1af41000 17 8201 ee000000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci DEVICES @@ -409,20 +409,20 @@ RHEV end it "does not set virtualization if /proc/bus/pci/devices not contains 1ab84000" do - devices=<<-DEVICES + devices = <<-DEVICES 0030 1af41000 a 8401 ee040000 0 0 0 0 0 40 1000 0 0 0 0 0 virtio-pci 0050 10110022 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 DEVICES expect(File).to receive(:exist?).with("/proc/bus/pci/devices").and_return(true) allow(File).to receive(:read).with("/proc/bus/pci/devices").and_return(devices) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end describe "when we are checking for lxc" do it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/ mounts" do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc 7:net_cls:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc 6:freezer:/lxc/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc @@ -441,7 +441,7 @@ CGROUP end it "sets lxc guest if /proc/self/cgroup exist and there are /lxc/ mounts" do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/lxc/vanilla 7:net_cls:/lxc/vanilla 6:freezer:/lxc/vanilla @@ -460,7 +460,7 @@ CGROUP end it "sets not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/Charlie 7:net_cls:/Charlie 6:freezer:/Charlie @@ -473,12 +473,12 @@ CGROUP expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true) allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end context "/proc/self/cgroup only has / mounts" do before(:each) do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/ 7:net_cls:/ 6:freezer:/ @@ -515,7 +515,7 @@ CGROUP plugin.run expect(plugin[:virtualization][:system]).to be_nil expect(plugin[:virtualization][:role]).to be_nil - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -523,13 +523,13 @@ CGROUP it "does not set virtualization if /proc/self/cgroup isn't there" do expect(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end describe "when we are checking for docker" do it "sets docker guest if /proc/self/cgroup exist and there are /docker/ mounts" do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc 7:net_cls:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc 6:freezer:/docker/baa660ed81bc81d262ac6e19486142aeec5fce2043e2a173eb2505c6fbed89bc @@ -548,7 +548,7 @@ CGROUP end it "sets docker guest if /proc/self/cgroup exist and there are /docker/ mounts" do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/docker/vanilla 7:net_cls:/docker/vanilla 6:freezer:/docker/vanilla @@ -569,7 +569,7 @@ CGROUP # Relevant at least starting docker 1.6.2, kernel 4.0.5 & systemd 224-1. # Doi not exactly know which software/version really matters here. it "should set docker guest if /proc/self/cgroup exists and there are /system.slice/docker- mounts (systemd managed cgroup)" do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:devices:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope 7:cpuset:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope 6:blkio:/system.slice/docker-47341c91be8d491cb3b8a475ad5b4aef6e79bf728cbb351c384e4a6c410f172f.scope @@ -588,7 +588,7 @@ CGROUP end it "sets not set anything if /proc/self/cgroup exist and the cgroup is named arbitrarily, it isn't necessarily lxc." do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/Charlie 7:net_cls:/Charlie 6:freezer:/Charlie @@ -601,12 +601,12 @@ CGROUP allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true) allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end context "/proc/self/cgroup only has / mounts" do before(:each) do - self_cgroup=<<-CGROUP + self_cgroup = <<-CGROUP 8:blkio:/ 7:net_cls:/ 6:freezer:/ @@ -619,7 +619,7 @@ CGROUP allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(true) allow(File).to receive(:read).with("/proc/self/cgroup").and_return(self_cgroup) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end @@ -639,13 +639,13 @@ CGROUP plugin.run expect(plugin[:virtualization][:system]).to be_nil expect(plugin[:virtualization][:role]).to be_nil - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end it "does not set virtualization if /proc/self/cgroup isn't there" do allow(File).to receive(:exist?).with("/proc/self/cgroup").and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end it "sets virtualization if /.dockerenv exists" do @@ -668,13 +668,13 @@ CGROUP allow(File).to receive(:exist?).with("/.dockerenv").and_return(false) allow(File).to receive(:exist?).with("/.dockerinit").and_return(false) plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end it "does not set virtualization if no tests match" do plugin.run - expect(plugin[:virtualization]).to eq({'systems' => {}}) + expect(plugin[:virtualization]).to eq({ "systems" => {} }) end end diff --git a/spec/unit/plugins/lua_spec.rb b/spec/unit/plugins/lua_spec.rb index 1698c7cd..056f30ee 100644 --- a/spec/unit/plugins/lua_spec.rb +++ b/spec/unit/plugins/lua_spec.rb @@ -18,8 +18,7 @@ # limitations under the License. # - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin lua" do diff --git a/spec/unit/plugins/mono_spec.rb b/spec/unit/plugins/mono_spec.rb index 952e00b0..6d4a3534 100644 --- a/spec/unit/plugins/mono_spec.rb +++ b/spec/unit/plugins/mono_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin mono" do diff --git a/spec/unit/plugins/netbsd/hostname_spec.rb b/spec/unit/plugins/netbsd/hostname_spec.rb index 7b955c17..4486a4c9 100644 --- a/spec/unit/plugins/netbsd/hostname_spec.rb +++ b/spec/unit/plugins/netbsd/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD hostname plugin" do before(:each) do diff --git a/spec/unit/plugins/netbsd/kernel_spec.rb b/spec/unit/plugins/netbsd/kernel_spec.rb index dc5a3fd8..6b716efc 100644 --- a/spec/unit/plugins/netbsd/kernel_spec.rb +++ b/spec/unit/plugins/netbsd/kernel_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD kernel plugin" do before(:each) do diff --git a/spec/unit/plugins/netbsd/platform_spec.rb b/spec/unit/plugins/netbsd/platform_spec.rb index 381fd339..37da17ab 100644 --- a/spec/unit/plugins/netbsd/platform_spec.rb +++ b/spec/unit/plugins/netbsd/platform_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "NetBSD plugin platform" do before(:each) do diff --git a/spec/unit/plugins/network_spec.rb b/spec/unit/plugins/network_spec.rb index 5b426334..8e37b24f 100644 --- a/spec/unit/plugins/network_spec.rb +++ b/spec/unit/plugins/network_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") def it_doesnt_fail it "doesnt fail" do @@ -55,7 +55,7 @@ describe Ohai::System, "Network Plugin" do "vr0" => { "type" => "vr", "number" => "0", - "flags" => ["UP", "BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST RUNNING SIMPLEX MULTICAST}, "addresses" => { "00:00:24:c9:5e:b8" => { "family" => "lladdr" @@ -64,23 +64,23 @@ describe Ohai::System, "Network Plugin" do "family" => "inet6", "zoneid" => "vr0", "prefixlen" => "64", - "scopeid" => "0x1" + "scopeid" => "0x1", }, "76.91.1.255" => { "family" => "inet", "netmask" => "255.255.252.0", - "broadcast" => "255.255.255.255" - } + "broadcast" => "255.255.255.255", + }, }, "arp" => { "76.91.1.255" => "00:00:24:c9:5e:b8", - "76.91.0.1" => "00:01:5c:24:8c:01" - } + "76.91.0.1" => "00:01:5c:24:8c:01", + }, }, "vr1" => { "type" => "vr", "number" => "1", - "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST}, "addresses" => { "00:00:24:c9:5e:b9" => { "family" => "lladdr" @@ -89,14 +89,14 @@ describe Ohai::System, "Network Plugin" do "family" => "inet6", "zoneid" => "vr1", "prefixlen" => "64", - "scopeid" => "0x2" - } - } + "scopeid" => "0x2", + }, + }, }, "vr2" => { "type" => "vr", "number" => "2", - "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST}, "addresses" => { "00:00:24:c9:5e:ba" => { "family" => "lladdr" @@ -105,14 +105,14 @@ describe Ohai::System, "Network Plugin" do "family" => "inet6", "zoneid" => "vr2", "prefixlen" => "64", - "scopeid" => "0x3" - } - } + "scopeid" => "0x3", + }, + }, }, "vr3" => { "type" => "vr", "number" => "3", - "flags" => ["UP", "BROADCAST", "RUNNING", "PROMISC", "SIMPLEX", "MULTICAST"], + "flags" => %w{UP BROADCAST RUNNING PROMISC SIMPLEX MULTICAST}, "addresses" => { "00:00:24:c9:5e:bb" => { "family" => "lladdr" @@ -121,60 +121,60 @@ describe Ohai::System, "Network Plugin" do "family" => "inet6", "zoneid" => "vr3", "prefixlen" => "64", - "scopeid" => "0x4" - } - } + "scopeid" => "0x4", + }, + }, }, "ipfw0" => { # OHAI-492: Ensure network plugin works with interfaces without addresses. "type" => "ipfw", "number" => "0", - "flags" => ["UP", "SIMPLEX", "MULTICAST"] + "flags" => %w{UP SIMPLEX MULTICAST}, }, "lo0" => { "type" => "lo", "number" => "0", - "flags" => ["UP", "LOOPBACK", "RUNNING", "MULTICAST"], + "flags" => %w{UP LOOPBACK RUNNING MULTICAST}, "addresses" => { "127.0.0.1" => { "family" => "inet", - "netmask" => "255.0.0.0" + "netmask" => "255.0.0.0", }, "::1" => { "family" => "inet6", - "prefixlen" => "128" + "prefixlen" => "128", }, "fe80::1" => { "family" => "inet6", "zoneid" => "lo0", "prefixlen" => "64", - "scopeid" => "0x8" - } - } + "scopeid" => "0x8", + }, + }, }, "bridge0" => { "type" => "bridge", "number" => "0", - "flags" => ["LEARNING", "DISCOVER", "AUTOEDGE", "AUTOPTP"], + "flags" => %w{LEARNING DISCOVER AUTOEDGE AUTOPTP}, "addresses" => { "02:20:6f:d2:c4:00" => { - "family"=>"lladdr" + "family" => "lladdr" }, "192.168.2.1" => { "family" => "inet", "netmask" => "255.255.255.0", - "broadcast" => "192.168.2.255" + "broadcast" => "192.168.2.255", }, "2001:470:d:cb4::1" => { "family" => "inet6", - "prefixlen" => "64" + "prefixlen" => "64", }, "fe80::cafe:babe:dead:beef" => { "family" => "inet6", "zoneid" => "bridge0", "prefixlen" => "64", - "scopeid" => "0x9" - } + "scopeid" => "0x9", + }, }, "arp" => { "192.168.2.142" => "60:67:20:75:a2:0c", @@ -184,27 +184,27 @@ describe Ohai::System, "Network Plugin" do "192.168.2.135" => "f8:0c:f3:d7:c6:b6", "192.168.2.165" => "f8:8f:ca:24:49:ad", "192.168.2.158" => "48:5d:60:1f:ea:d1", - "192.168.2.150" => "60:a4:4c:60:b3:d9" - } + "192.168.2.150" => "60:a4:4c:60:b3:d9", + }, }, "gif0" => { "type" => "gif", "number" => "0", - "flags" => ["UP", "POINTOPOINT", "RUNNING", "MULTICAST"], + "flags" => %w{UP POINTOPOINT RUNNING MULTICAST}, "addresses" => { "fe80::200:24ff:fec9:5eb8" => { "family" => "inet6", "zoneid" => "gif0", "prefixlen" => "64", - "scopeid" => "0xa" + "scopeid" => "0xa", } - } - } + }, + }, }, "default_gateway" => "76.91.0.1", "default_interface" => "vr0", "default_inet6_gateway" => "2001:470:d:cb4::2", - "default_inet6_interface" => "bridge0" + "default_inet6_interface" => "bridge0", } }, "linux" => { @@ -213,32 +213,32 @@ describe Ohai::System, "Network Plugin" do # have just removed the neighbour and route entries by hand "interfaces" => { "lo" => { - "flags" => ["LOOPBACK", "UP"], + "flags" => %w{LOOPBACK UP}, "addresses" => { "::1" => { "scope" => "Node", "prefixlen" => "128", - "family" => "inet6" + "family" => "inet6", }, "127.0.0.1" => { "scope" => "Node", "netmask" => "255.0.0.0", "prefixlen" => "8", - "family" => "inet" - } + "family" => "inet", + }, }, "mtu" => "16436", "encapsulation" => "Loopback", - "state" => "unknown" + "state" => "unknown", }, "eth0" => { - "flags" => ["BROADCAST", "MULTICAST", "UP"], + "flags" => %w{BROADCAST MULTICAST UP}, "number" => "0", "addresses" => { "fe80::216:3eff:fe2f:3679" => { "scope" => "Link", "prefixlen" => "64", - "family" => "inet6" + "family" => "inet6", }, "00:16:3E:2F:36:79" => { "family" => "lladdr" @@ -248,27 +248,27 @@ describe Ohai::System, "Network Plugin" do "netmask" => "255.255.255.0", "broadcast" => "192.168.66.255", "prefixlen" => "24", - "family" => "inet" + "family" => "inet", }, "3ffe:1111:2222::33" => { "prefixlen" => "48", "family" => "inet6", "scope" => "Global", - "state" => "up" - } + "state" => "up", + }, }, "mtu" => "1500", "type" => "eth", - "encapsulation" => "Ethernet" + "encapsulation" => "Ethernet", }, "eth1" => { - "flags" => ["BROADCAST", "MULTICAST", "UP"], + "flags" => %w{BROADCAST MULTICAST UP}, "number" => "1", "addresses" => { "fe80::216:3eff:fe2f:3680" => { "scope" => "Link", "prefixlen" => "64", - "family" => "inet6" + "family" => "inet6", }, "00:16:3E:2F:36:80" => { "family" => "lladdr" @@ -278,23 +278,23 @@ describe Ohai::System, "Network Plugin" do "netmask" => "255.255.255.0", "broadcast" => "192.168.99.255", "prefixlen" => "24", - "family" => "inet" + "family" => "inet", }, "3ffe:1111:3333::1" => { "prefixlen" => "48", "family" => "inet6", - "scope" => "Global" - } + "scope" => "Global", + }, }, "mtu" => "1500", "type" => "eth", - "encapsulation" => "Ethernet" - } + "encapsulation" => "Ethernet", + }, }, "default_gateway" => "192.168.66.15", "default_interface" => "eth0", "default_inet6_gateway" => "3ffe:1111:2222::", - "default_inet6_interface" => "eth0" + "default_inet6_interface" => "eth0", } }, "windows" => { @@ -306,26 +306,26 @@ describe Ohai::System, "Network Plugin" do "prefixlen" => "24", "netmask" => "255.255.255.0", "broadcast" => "172.19.0.255", - "family" => "inet" + "family" => "inet", }, "fe80::698d:3e37:7950:b28c" => { "prefixlen" => "64", "family" => "inet6", - "scope" => "Link" + "scope" => "Link", }, "52:54:44:66:66:02" => { "family" => "lladdr" - } + }, }, "mtu" => nil, "type" => "Ethernet 802.3", - "encapsulation" => "Ethernet" + "encapsulation" => "Ethernet", } }, "default_gateway" => "172.19.0.1", - "default_interface" => "0xb" + "default_interface" => "0xb", } - } + }, } describe "on linux" do @@ -375,7 +375,7 @@ describe Ohai::System, "Network Plugin" do describe "ipv4 interface has no ARP" do before do - @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,kv| kv["family"] == "lladdr" } + @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, kv| kv["family"] == "lladdr" } # not really checked by this pluging @plugin["network"]["interfaces"]["eth0"]["flags"] << "NOARP" @plugin["network"]["default_inet6_gateway"] = "3ffe:1111:3333::" @@ -446,7 +446,7 @@ describe Ohai::System, "Network Plugin" do describe "no ip address for the given default interface/gateway" do before do - @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]} + @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] } end it_doesnt_fail @@ -475,8 +475,8 @@ describe Ohai::System, "Network Plugin" do @plugin["network"]["default_interface"] = nil @plugin["network"]["default_inet6_gateway"] = nil @plugin["network"]["default_inet6_interface"] = nil - @plugin["network"]["interfaces"].each do |i,iv| - iv["addresses"].delete_if{|k,kv| %w[inet inet6].include? kv["family"]} + @plugin["network"]["interfaces"].each do |i, iv| + iv["addresses"].delete_if { |k, kv| %w{inet inet6}.include? kv["family"] } end end @@ -503,28 +503,28 @@ describe Ohai::System, "Network Plugin" do describe "bigger prefix not set on the default interface" do before do @plugin["network"]["interfaces"]["eth2"] = { - "flags" => ["BROADCAST", "MULTICAST", "UP"], + "flags" => %w{BROADCAST MULTICAST UP}, "number" => "2", "addresses" => { "fe80::216:3eff:fe2f:3681" => { "scope" => "Link", "prefixlen" => "64", - "family" => "inet6" + "family" => "inet6", }, - "00:16:3E:2F:36:81" => {"family" => "lladdr"}, + "00:16:3E:2F:36:81" => { "family" => "lladdr" }, "192.168.66.99" => { "scope" => "Global", "netmask" => "255.255.255.128", "broadcast" => "192.168.99.127", "prefixlen" => "25", - "family" => "inet" + "family" => "inet", }, "3ffe:1111:2222:0:4444::1" => { "prefixlen" => "64", "family" => "inet6", - "scope" => "Global" - } - } + "scope" => "Global", + }, + }, } end @@ -545,12 +545,12 @@ describe Ohai::System, "Network Plugin" do "netmask" => "255.255.255.128", "broadcast" => "192.168.66.127", "prefixlen" => "25", - "family" => "inet" + "family" => "inet", } @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222:0:4444::1"] = { "prefixlen" => "64", "family" => "inet6", - "scope" => "Global" + "scope" => "Global", } end @@ -567,28 +567,28 @@ describe Ohai::System, "Network Plugin" do describe "smallest ip not set on the default_interface" do before do @plugin["network"]["interfaces"]["eth2"] = { - "flags" => ["BROADCAST", "MULTICAST", "UP"], + "flags" => %w{BROADCAST MULTICAST UP}, "number" => "2", "addresses" => { "fe80::216:3eff:fe2f:3681" => { "scope" => "Link", "prefixlen" => "64", - "family" => "inet6" + "family" => "inet6", }, - "00:16:3E:2F:36:81" => {"family" => "lladdr"}, + "00:16:3E:2F:36:81" => { "family" => "lladdr" }, "192.168.66.32" => { "scope" => "Global", "netmask" => "255.255.255.0", "broadcast" => "192.168.66.255", "prefixlen" => "24", - "family" => "inet" + "family" => "inet", }, "3ffe:1111:2222::32" => { "prefixlen" => "48", "family" => "inet6", - "scope" => "Global" - } - } + "scope" => "Global", + }, + }, } end @@ -609,12 +609,12 @@ describe Ohai::System, "Network Plugin" do "netmask" => "255.255.255.0", "broadcast" => "192.168.66.255", "prefixlen" => "24", - "family" => "inet" + "family" => "inet", } @plugin["network"]["interfaces"]["eth0"]["addresses"]["3ffe:1111:2222::32"] = { "prefixlen" => "48", "family" => "inet6", - "scope" => "Global" + "scope" => "Global", } end @@ -637,7 +637,7 @@ describe Ohai::System, "Network Plugin" do @plugin["network"]["default_inet6_gateway"] = nil @plugin["network"]["default_inet6_interface"] = nil # removing inet* addresses from eth0, to complicate things a bit - @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if{|k,v| %w[inet inet6].include? v["family"]} + @plugin["network"]["interfaces"]["eth0"]["addresses"].delete_if { |k, v| %w{inet inet6}.include? v["family"] } end it_populates_ipaddress_attributes @@ -660,7 +660,7 @@ describe Ohai::System, "Network Plugin" do @plugin["network"]["default_inet6_gateway"] = nil @plugin["network"]["default_inet6_interface"] = nil # just changing scopes to lInK for eth0 addresses - @plugin["network"]["interfaces"]["eth0"]["addresses"].each{|k,v| v[:scope]="lInK" if %w[inet inet6].include? v["family"]} + @plugin["network"]["interfaces"]["eth0"]["addresses"].each { |k, v| v[:scope] = "lInK" if %w{inet inet6}.include? v["family"] } end it_populates_ipaddress_attributes @@ -719,7 +719,7 @@ describe Ohai::System, "Network Plugin" do "scope" => "host", "netmask" => "255.255.255.255", "prefixlen" => "32", - "family" => "inet" + "family" => "inet", } end @@ -737,29 +737,29 @@ describe Ohai::System, "Network Plugin" do describe "point to point address" do before do @plugin["network"]["interfaces"]["eth2"] = { - "flags" => ["POINTOPOINT", "BROADCAST", "MULTICAST", "UP"], + "flags" => %w{POINTOPOINT BROADCAST MULTICAST UP}, "number" => "2", "addresses" => { "fe80::216:3eff:fe2f:3681" => { "scope" => "Link", "prefixlen" => "64", - "family" => "inet6" + "family" => "inet6", }, - "00:16:3E:2F:36:81" => {"family" => "lladdr"}, + "00:16:3E:2F:36:81" => { "family" => "lladdr" }, "192.168.66.99" => { "scope" => "Global", "netmask" => "255.255.255.255", "peer" => "192.168.99.126", "prefixlen" => "32", - "family" => "inet" + "family" => "inet", }, "3ffe:1111:2222:0:4444::1" => { "prefixlen" => "128", "peer" => "3ffe:1111:2222:0:4444::2", "family" => "inet6", - "scope" => "Global" - } - } + "scope" => "Global", + }, + }, } @plugin["network"]["default_gateway"] = "192.168.99.126" @plugin["network"]["default_interface"] = "eth2" @@ -781,8 +781,8 @@ describe Ohai::System, "Network Plugin" do before do @plugin["network"]["default_gateway"] = nil @plugin["network"]["default_interface"] = nil - @plugin["network"]["interfaces"].each do |i,iv| - iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" } + @plugin["network"]["interfaces"].each do |i, iv| + iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" } end end @@ -820,9 +820,9 @@ describe Ohai::System, "Network Plugin" do before do @plugin["network"]["default_gateway"] = nil @plugin["network"]["default_interface"] = nil - @plugin["network"]["interfaces"].each do |i,iv| - next if i == 'lo' - iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" } + @plugin["network"]["interfaces"].each do |i, iv| + next if i == "lo" + iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" } end end @@ -863,16 +863,16 @@ describe Ohai::System, "Network Plugin" do @expected_results = { "freebsd" => { "ip6address" => "2001:470:d:cb4::1", - "macaddress" => "02:20:6f:d2:c4:00" + "macaddress" => "02:20:6f:d2:c4:00", }, "linux" => { "ip6address" => "3ffe:1111:2222::33", - "macaddress" => "00:16:3E:2F:36:79" + "macaddress" => "00:16:3E:2F:36:79", }, "windows" => { "ip6address" => "fe80::698d:3e37:7950:b28c", - "macaddress" => "00:AA:BB:CC:DD:EE" - } + "macaddress" => "00:AA:BB:CC:DD:EE", + }, } end @@ -897,16 +897,16 @@ describe Ohai::System, "Network Plugin" do @expected_results = { "freebsd" => { "ipaddress" => "76.91.1.255", - "macaddress" => "00:00:24:c9:5e:b8" + "macaddress" => "00:00:24:c9:5e:b8", }, "linux" => { "ipaddress" => "192.168.66.33", - "macaddress" => "00:16:3E:2F:36:79" + "macaddress" => "00:16:3E:2F:36:79", }, "windows" => { "ipaddress" => "172.19.0.130", - "macaddress" => "52:54:44:66:66:02" - } + "macaddress" => "52:54:44:66:66:02", + }, } end @@ -928,9 +928,9 @@ describe Ohai::System, "Network Plugin" do before do @plugin["network"]["default_gateway"] = nil @plugin["network"]["default_interface"] = nil - @plugin["network"]["interfaces"].each do |i,iv| + @plugin["network"]["interfaces"].each do |i, iv| if iv.has_key? "addresses" - iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" } + iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" } end end @plugin["ip6address"] = "3ffe:8888:9999::1" @@ -943,7 +943,7 @@ describe Ohai::System, "Network Plugin" do }, "windows" => { "macaddress" => "52:54:44:66:66:02" - } + }, } end @@ -982,16 +982,16 @@ describe Ohai::System, "Network Plugin" do @expected_results = { "freebsd" => { "ipaddress" => "76.91.1.255", - "macaddress" => "00:00:24:c9:5e:b8" + "macaddress" => "00:00:24:c9:5e:b8", }, "linux" => { "ipaddress" => "192.168.66.33", - "macaddress" => "00:16:3E:2F:36:79" + "macaddress" => "00:16:3E:2F:36:79", }, "windows" => { "ipaddress" => "172.19.0.130", - "macaddress" => "52:54:44:66:66:02" - } + "macaddress" => "52:54:44:66:66:02", + }, } end @@ -1013,9 +1013,9 @@ describe Ohai::System, "Network Plugin" do before do @plugin["network"]["default_gateway"] = nil @plugin["network"]["default_interface"] = nil - @plugin["network"]["interfaces"].each do |i,iv| + @plugin["network"]["interfaces"].each do |i, iv| if iv.has_key? "addresses" - iv["addresses"].delete_if{|k,kv| kv["family"] == "inet" } + iv["addresses"].delete_if { |k, kv| kv["family"] == "inet" } end end @plugin["macaddress"] = "00:AA:BB:CC:DD:EE" diff --git a/spec/unit/plugins/nodejs_spec.rb b/spec/unit/plugins/nodejs_spec.rb index 135c7707..af6af616 100644 --- a/spec/unit/plugins/nodejs_spec.rb +++ b/spec/unit/plugins/nodejs_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin nodejs" do diff --git a/spec/unit/plugins/ohai_spec.rb b/spec/unit/plugins/ohai_spec.rb index c350b0a3..530df962 100644 --- a/spec/unit/plugins/ohai_spec.rb +++ b/spec/unit/plugins/ohai_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin ohai" do before(:each) do diff --git a/spec/unit/plugins/ohai_time_spec.rb b/spec/unit/plugins/ohai_time_spec.rb index 633dd2f6..e1fe0e48 100644 --- a/spec/unit/plugins/ohai_time_spec.rb +++ b/spec/unit/plugins/ohai_time_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin ohai_time" do before(:each) do diff --git a/spec/unit/plugins/openbsd/hostname_spec.rb b/spec/unit/plugins/openbsd/hostname_spec.rb index 6ee3c604..d2d320a0 100644 --- a/spec/unit/plugins/openbsd/hostname_spec.rb +++ b/spec/unit/plugins/openbsd/hostname_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD hostname plugin" do before(:each) do diff --git a/spec/unit/plugins/openbsd/kernel_spec.rb b/spec/unit/plugins/openbsd/kernel_spec.rb index 689c8d7e..f80de3bb 100644 --- a/spec/unit/plugins/openbsd/kernel_spec.rb +++ b/spec/unit/plugins/openbsd/kernel_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD kernel plugin" do before(:each) do diff --git a/spec/unit/plugins/openbsd/platform_spec.rb b/spec/unit/plugins/openbsd/platform_spec.rb index 39bfbf8c..3c3759ae 100644 --- a/spec/unit/plugins/openbsd/platform_spec.rb +++ b/spec/unit/plugins/openbsd/platform_spec.rb @@ -16,8 +16,7 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "OpenBSD plugin platform" do before(:each) do diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb index 2edc111d..0024eb5a 100644 --- a/spec/unit/plugins/openstack_spec.rb +++ b/spec/unit/plugins/openstack_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ohai/plugins/openstack' +require "spec_helper" +require "ohai/plugins/openstack" describe "OpenStack Plugin" do @@ -53,7 +53,7 @@ describe "OpenStack Plugin" do before do expect(openstack_plugin).to receive(:can_metadata_connect?). - with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80). + with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80). and_return(false) end @@ -114,7 +114,7 @@ EOM "aki-id" => "aki-00000036", "block-device-mapping/" => "ami\nroot", "block-device-mapping/ami" => "vda", - "block-device-mapping/root" => "/dev/vda" + "block-device-mapping/root" => "/dev/vda", } end @@ -148,13 +148,13 @@ EOM def expect_get_response(url, response_body) expect(http_client).to receive(:get_response). - with(url,nil,nil). + with(url, nil, nil). and_return(double("HTTP Response", :code => "200", :body => response_body)) end before do expect(openstack_plugin).to receive(:can_metadata_connect?). - with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80). + with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80). and_return(true) allow(Net::HTTP).to receive(:start). @@ -171,99 +171,97 @@ EOM expect_get_response( URI.parse("#{openstack_metadata_endpoint}#{openstack_metadata_version}/meta_data.json"), - openstack_metadata_values + openstack_metadata_values, ) openstack_plugin.run end it "reads the reservation_id from the metadata service" do - expect(ohai_data['openstack']['reservation_id']).to eq("r-4tjvl99h") + expect(ohai_data["openstack"]["reservation_id"]).to eq("r-4tjvl99h") end it "reads the public_keys_0_openssh_key from the metadata service" do - expect(ohai_data['openstack']['public_keys_0_openssh_key']).to eq("SSH KEY DATA") + expect(ohai_data["openstack"]["public_keys_0_openssh_key"]).to eq("SSH KEY DATA") end it "reads the security_groups from the metadata service" do - expect(ohai_data['openstack']['security_groups']).to eq(["default"]) + expect(ohai_data["openstack"]["security_groups"]).to eq(["default"]) end it "reads the public_ipv4 from the metadata service" do - expect(ohai_data['openstack']['public_ipv4']).to eq("") + expect(ohai_data["openstack"]["public_ipv4"]).to eq("") end it "reads the ami_manifest_path from the metadata service" do - expect(ohai_data['openstack']['ami_manifest_path']).to eq("FIXME") + expect(ohai_data["openstack"]["ami_manifest_path"]).to eq("FIXME") end it "reads the instance_type from the metadata service" do - expect(ohai_data['openstack']['instance_type']).to eq("opc-tester") + expect(ohai_data["openstack"]["instance_type"]).to eq("opc-tester") end it "reads the instance_id from the metadata service" do - expect(ohai_data['openstack']['instance_id']).to eq("i-0000162a") + expect(ohai_data["openstack"]["instance_id"]).to eq("i-0000162a") end it "reads the local_ipv4 from the metadata service" do - expect(ohai_data['openstack']['local_ipv4']).to eq("172.31.7.23") + expect(ohai_data["openstack"]["local_ipv4"]).to eq("172.31.7.23") end it "reads the ari_id from the metadata service" do - expect(ohai_data['openstack']['ari_id']).to eq("ari-00000037") + expect(ohai_data["openstack"]["ari_id"]).to eq("ari-00000037") end it "reads the local_hostname from the metadata service" do - expect(ohai_data['openstack']['local_hostname']).to eq("ohai-7-system-test.opscode.us") + expect(ohai_data["openstack"]["local_hostname"]).to eq("ohai-7-system-test.opscode.us") end it "reads the placement_availability_zone from the metadata service" do - expect(ohai_data['openstack']['placement_availability_zone']).to eq("nova") + expect(ohai_data["openstack"]["placement_availability_zone"]).to eq("nova") end it "reads the ami_launch_index from the metadata service" do - expect(ohai_data['openstack']['ami_launch_index']).to eq("0") + expect(ohai_data["openstack"]["ami_launch_index"]).to eq("0") end it "reads the public_hostname from the metadata service" do - expect(ohai_data['openstack']['public_hostname']).to eq("ohai-7-system-test.opscode.us") + expect(ohai_data["openstack"]["public_hostname"]).to eq("ohai-7-system-test.opscode.us") end it "reads the hostname from the metadata service" do - expect(ohai_data['openstack']['hostname']).to eq("ohai-7-system-test.opscode.us") + expect(ohai_data["openstack"]["hostname"]).to eq("ohai-7-system-test.opscode.us") end it "reads the ami_id from the metadata service" do - expect(ohai_data['openstack']['ami_id']).to eq("ami-00000035") + expect(ohai_data["openstack"]["ami_id"]).to eq("ami-00000035") end it "reads the instance_action from the metadata service" do - expect(ohai_data['openstack']['instance_action']).to eq("none") + expect(ohai_data["openstack"]["instance_action"]).to eq("none") end it "reads the aki_id from the metadata service" do - expect(ohai_data['openstack']['aki_id']).to eq("aki-00000036") + expect(ohai_data["openstack"]["aki_id"]).to eq("aki-00000036") end it "reads the block_device_mapping_ami from the metadata service" do - expect(ohai_data['openstack']['block_device_mapping_ami']).to eq("vda") + expect(ohai_data["openstack"]["block_device_mapping_ami"]).to eq("vda") end it "reads the block_device_mapping_root from the metadata service" do - expect(ohai_data['openstack']['block_device_mapping_root']).to eq("/dev/vda") + expect(ohai_data["openstack"]["block_device_mapping_root"]).to eq("/dev/vda") end it "reads the provider from the metadata service" do - expect(ohai_data['openstack']['provider']).to eq("openstack") + expect(ohai_data["openstack"]["provider"]).to eq("openstack") end - context 'Retreive openStack specific metadata' do + context "Retreive openStack specific metadata" do it "reads the availability_zone from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['availability_zone']).to eq('nova') + expect(ohai_data["openstack"]["metadata"]["availability_zone"]).to eq("nova") end it "reads the hostname from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['hostname']).to eq('ohai.novalocal') + expect(ohai_data["openstack"]["metadata"]["hostname"]).to eq("ohai.novalocal") end it "reads the launch_index from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['launch_index']).to eq(0) + expect(ohai_data["openstack"]["metadata"]["launch_index"]).to eq(0) end it "reads the meta from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['meta']).to eq({ "priority" => "low", "role" => "ohaiserver"}) + expect(ohai_data["openstack"]["metadata"]["meta"]).to eq({ "priority" => "low", "role" => "ohaiserver" }) end it "reads the name from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['name']).to eq('ohai_spec') + expect(ohai_data["openstack"]["metadata"]["name"]).to eq("ohai_spec") end it "reads the public_keys from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['public_keys']).to eq({"mykey" => "SSH KEY DATA"}) + expect(ohai_data["openstack"]["metadata"]["public_keys"]).to eq({ "mykey" => "SSH KEY DATA" }) end it "reads the uuid from the openstack metadata service" do - expect(ohai_data['openstack']['metadata']['uuid']).to eq('00000000-0000-0000-0000-100000000000') + expect(ohai_data["openstack"]["metadata"]["uuid"]).to eq("00000000-0000-0000-0000-100000000000") end end end - end end - diff --git a/spec/unit/plugins/os_spec.rb b/spec/unit/plugins/os_spec.rb index 76d55c4e..3cff244d 100644 --- a/spec/unit/plugins/os_spec.rb +++ b/spec/unit/plugins/os_spec.rb @@ -16,10 +16,9 @@ # limitations under the License. # +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG['host_os'] +ORIGINAL_CONFIG_HOST_OS = ::RbConfig::CONFIG["host_os"] describe Ohai::System, "plugin os" do before(:each) do @@ -29,7 +28,7 @@ describe Ohai::System, "plugin os" do end after do - ::RbConfig::CONFIG['host_os'] = ORIGINAL_CONFIG_HOST_OS + ::RbConfig::CONFIG["host_os"] = ORIGINAL_CONFIG_HOST_OS end it "should set os_version to kernel_release" do @@ -39,7 +38,7 @@ describe Ohai::System, "plugin os" do describe "on linux" do before(:each) do - ::RbConfig::CONFIG['host_os'] = "linux" + ::RbConfig::CONFIG["host_os"] = "linux" end it "should set the os to linux" do @@ -50,7 +49,7 @@ describe Ohai::System, "plugin os" do describe "on darwin" do before(:each) do - ::RbConfig::CONFIG['host_os'] = "darwin10.0" + ::RbConfig::CONFIG["host_os"] = "darwin10.0" end it "should set the os to darwin" do @@ -61,7 +60,7 @@ describe Ohai::System, "plugin os" do describe "on solaris" do before do - ::RbConfig::CONFIG['host_os'] = "solaris2.42" #heh + ::RbConfig::CONFIG["host_os"] = "solaris2.42" #heh end it "sets the os to solaris2" do @@ -72,7 +71,7 @@ describe Ohai::System, "plugin os" do describe "on something we have never seen before, but ruby has" do before do - ::RbConfig::CONFIG['host_os'] = "tron" + ::RbConfig::CONFIG["host_os"] = "tron" end it "sets the os to the ruby 'host_os'" do diff --git a/spec/unit/plugins/packages_spec.rb b/spec/unit/plugins/packages_spec.rb index 70016ba2..169eeac6 100644 --- a/spec/unit/plugins/packages_spec.rb +++ b/spec/unit/plugins/packages_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -describe Ohai::System, 'plugin packages' do +describe Ohai::System, "plugin packages" do context "when the packages plugin is disabled" do before do Ohai.config[:plugin][:packages][:enabled] = false @@ -28,7 +28,7 @@ describe Ohai::System, 'plugin packages' do end let(:plugin) do - get_plugin('packages').tap do |plugin| + get_plugin("packages").tap do |plugin| plugin[:platform_family] = platform_family end end @@ -49,222 +49,222 @@ describe Ohai::System, 'plugin packages' do Ohai.config[:plugin][:packages][:enabled] = true end - context 'on debian' do + context "on debian" do let(:plugin) do - get_plugin('packages').tap do |plugin| - plugin[:platform_family] = 'debian' + get_plugin("packages").tap do |plugin| + plugin[:platform_family] = "debian" end end let(:stdout) do - File.read(File.join(SPEC_PLUGIN_PATH, 'dpkg-query.output')) + File.read(File.join(SPEC_PLUGIN_PATH, "dpkg-query.output")) end before(:each) do allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out) - .with('dpkg-query -W') - .and_return(mock_shell_out(0, stdout, '')) + .with("dpkg-query -W") + .and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'calls dpkg query' do + it "calls dpkg query" do expect(plugin).to receive(:shell_out) - .with('dpkg-query -W') - .and_return(mock_shell_out(0, stdout, '')) + .with("dpkg-query -W") + .and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'gets packages and versions' do - expect(plugin[:packages]['vim-common'][:version]).to eq('2:7.4.052-1ubuntu3') + it "gets packages and versions" do + expect(plugin[:packages]["vim-common"][:version]).to eq("2:7.4.052-1ubuntu3") end end - context 'on fedora' do + context "on fedora" do let(:plugin) do - get_plugin('packages').tap do |plugin| - plugin[:platform_family] = 'fedora' + get_plugin("packages").tap do |plugin| + plugin[:platform_family] = "fedora" end end let(:format) { Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n' } let(:stdout) do - File.read(File.join(SPEC_PLUGIN_PATH, 'rpmquery.output')) + File.read(File.join(SPEC_PLUGIN_PATH, "rpmquery.output")) end before(:each) do allow(plugin).to receive(:collect_os).and_return(:linux) - allow(plugin).to receive(:shell_out).with("rpm -qa --queryformat #{format}").and_return(mock_shell_out(0, stdout, '')) + allow(plugin).to receive(:shell_out).with("rpm -qa --queryformat #{format}").and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'calls rpm -qa' do + it "calls rpm -qa" do expect(plugin).to receive(:shell_out) .with("rpm -qa --queryformat #{format}") - .and_return(mock_shell_out(0, stdout, '')) + .and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'gets packages and versions/release' do - expect(plugin[:packages]['vim-common'][:version]).to eq('7.2.411') - expect(plugin[:packages]['vim-common'][:release]).to eq('1.8.el6') + it "gets packages and versions/release" do + expect(plugin[:packages]["vim-common"][:version]).to eq("7.2.411") + expect(plugin[:packages]["vim-common"][:release]).to eq("1.8.el6") end end - context 'on windows', :windows_only do - require 'wmi-lite' + context "on windows", :windows_only do + require "wmi-lite" let(:plugin) do - get_plugin('packages').tap do |plugin| - plugin[:platform_family] = 'windows' + get_plugin("packages").tap do |plugin| + plugin[:platform_family] = "windows" end end let(:win32_product_output) do - [{ 'assignmenttype' => 0, - 'caption' => 'NXLOG-CE', - 'description' => 'NXLOG-CE', - 'helplink' => nil, - 'helptelephone' => nil, - 'identifyingnumber' => '{22FA28AB-3C1B-438B-A8B5-E23892C8B567}', - 'installdate' => '20150511', - 'installdate2' => nil, - 'installlocation' => nil, - 'installsource' => 'C:\\chef\\cache\\', - 'installstate' => 5, - 'language' => '1033', - 'localpackage' => 'C:\\Windows\\Installer\\30884.msi', - 'name' => 'NXLOG-CE', - 'packagecache' => 'C:\\Windows\\Installer\\30884.msi', - 'packagecode' => '{EC3A13C4-4634-47FC-9662-DC293CB96F9F}', - 'packagename' => 'nexlog-ce-2.8.1248.msi', - 'productid' => nil, - 'regcompany' => nil, - 'regowner' => nil, - 'skunumber' => nil, - 'transforms' => nil, - 'urlinfoabout' => nil, - 'urlupdateinfo' => nil, - 'vendor' => 'nxsec.com', - 'version' => '2.8.1248', - 'wordcount' => 2 }, - { 'assignmenttype' => 1, - 'caption' => 'Chef Development Kit v0.7.0', - 'description' => 'Chef Development Kit v0.7.0', - 'helplink' => 'http://www.getchef.com/support/', - 'helptelephone' => nil, - 'identifyingnumber' => '{90754A33-404C-4172-8F3B-7F04CE98011C}', - 'installdate' => '20150925', 'installdate2' => nil, - 'installlocation' => nil, - 'installsource' => 'C:\\Users\\skhajamohid1\\Downloads\\', - 'installstate' => 5, 'language' => '1033', - 'localpackage' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi', - 'name' => 'Chef Development Kit v0.7.0', - 'packagecache' => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi', - 'packagecode' => '{9B82FB86-40AE-4CDF-9DE8-97574F9395B9}', - 'packagename' => 'chefdk-0.7.0-1 (2).msi', - 'productid' => nil, - 'regcompany' => nil, - 'regowner' => nil, - 'skunumber' => nil, - 'transforms' => nil, - 'urlinfoabout' => nil, - 'urlupdateinfo' => nil, - 'vendor' => "\"Chef Software, Inc. \"", - 'version' => '0.7.0.1', - 'wordcount' => 2 }] + [{ "assignmenttype" => 0, + "caption" => "NXLOG-CE", + "description" => "NXLOG-CE", + "helplink" => nil, + "helptelephone" => nil, + "identifyingnumber" => "{22FA28AB-3C1B-438B-A8B5-E23892C8B567}", + "installdate" => "20150511", + "installdate2" => nil, + "installlocation" => nil, + "installsource" => 'C:\\chef\\cache\\', + "installstate" => 5, + "language" => "1033", + "localpackage" => 'C:\\Windows\\Installer\\30884.msi', + "name" => "NXLOG-CE", + "packagecache" => 'C:\\Windows\\Installer\\30884.msi', + "packagecode" => "{EC3A13C4-4634-47FC-9662-DC293CB96F9F}", + "packagename" => "nexlog-ce-2.8.1248.msi", + "productid" => nil, + "regcompany" => nil, + "regowner" => nil, + "skunumber" => nil, + "transforms" => nil, + "urlinfoabout" => nil, + "urlupdateinfo" => nil, + "vendor" => "nxsec.com", + "version" => "2.8.1248", + "wordcount" => 2 }, + { "assignmenttype" => 1, + "caption" => "Chef Development Kit v0.7.0", + "description" => "Chef Development Kit v0.7.0", + "helplink" => "http://www.getchef.com/support/", + "helptelephone" => nil, + "identifyingnumber" => "{90754A33-404C-4172-8F3B-7F04CE98011C}", + "installdate" => "20150925", "installdate2" => nil, + "installlocation" => nil, + "installsource" => 'C:\\Users\\skhajamohid1\\Downloads\\', + "installstate" => 5, "language" => "1033", + "localpackage" => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi', + "name" => "Chef Development Kit v0.7.0", + "packagecache" => 'C:\\WINDOWS\\Installer\\d9e1ca7.msi', + "packagecode" => "{9B82FB86-40AE-4CDF-9DE8-97574F9395B9}", + "packagename" => "chefdk-0.7.0-1 (2).msi", + "productid" => nil, + "regcompany" => nil, + "regowner" => nil, + "skunumber" => nil, + "transforms" => nil, + "urlinfoabout" => nil, + "urlupdateinfo" => nil, + "vendor" => "\"Chef Software, Inc. \"", + "version" => "0.7.0.1", + "wordcount" => 2 }] end before(:each) do allow(plugin).to receive(:collect_os).and_return(:windows) - expect_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_Product').and_return(win32_product_output) + expect_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_Product").and_return(win32_product_output) plugin.run end - it 'gets package info' do - expect(plugin[:packages]['Chef Development Kit v0.7.0'][:version]).to eq('0.7.0.1') - expect(plugin[:packages]['Chef Development Kit v0.7.0'][:vendor]).to eq("\"Chef Software, Inc. \"") - expect(plugin[:packages]['Chef Development Kit v0.7.0'][:installdate]).to eq('20150925') + it "gets package info" do + expect(plugin[:packages]["Chef Development Kit v0.7.0"][:version]).to eq("0.7.0.1") + expect(plugin[:packages]["Chef Development Kit v0.7.0"][:vendor]).to eq("\"Chef Software, Inc. \"") + expect(plugin[:packages]["Chef Development Kit v0.7.0"][:installdate]).to eq("20150925") - expect(plugin[:packages]['NXLOG-CE'][:version]).to eq('2.8.1248') - expect(plugin[:packages]['NXLOG-CE'][:vendor]).to eq('nxsec.com') - expect(plugin[:packages]['NXLOG-CE'][:installdate]).to eq('20150511') + expect(plugin[:packages]["NXLOG-CE"][:version]).to eq("2.8.1248") + expect(plugin[:packages]["NXLOG-CE"][:vendor]).to eq("nxsec.com") + expect(plugin[:packages]["NXLOG-CE"][:installdate]).to eq("20150511") end end - context 'on aix' do - let(:plugin) { get_plugin('packages') } + context "on aix" do + let(:plugin) { get_plugin("packages") } let(:stdout) do - File.read(File.join(SPEC_PLUGIN_PATH, 'lslpp.output')) + File.read(File.join(SPEC_PLUGIN_PATH, "lslpp.output")) end before(:each) do allow(plugin).to receive(:collect_os).and_return(:aix) - allow(plugin).to receive(:shell_out).with('lslpp -L -q -c').and_return(mock_shell_out(0, stdout, '')) + allow(plugin).to receive(:shell_out).with("lslpp -L -q -c").and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'calls lslpp -L -q -c' do + it "calls lslpp -L -q -c" do expect(plugin).to receive(:shell_out) - .with('lslpp -L -q -c') - .and_return(mock_shell_out(0, stdout, '')) + .with("lslpp -L -q -c") + .and_return(mock_shell_out(0, stdout, "")) plugin.run end - it 'gets packages with version' do - expect(plugin[:packages]['chef'][:version]).to eq('12.5.1.1') + it "gets packages with version" do + expect(plugin[:packages]["chef"][:version]).to eq("12.5.1.1") end end - context 'on solaris2' do - let(:plugin) { get_plugin('packages') } + context "on solaris2" do + let(:plugin) { get_plugin("packages") } let(:pkglist_output) do - File.read(File.join(SPEC_PLUGIN_PATH, 'pkglist.output')) + File.read(File.join(SPEC_PLUGIN_PATH, "pkglist.output")) end let(:pkginfo_output) do - File.read(File.join(SPEC_PLUGIN_PATH, 'pkginfo.output')) + File.read(File.join(SPEC_PLUGIN_PATH, "pkginfo.output")) end before(:each) do allow(plugin).to receive(:collect_os).and_return(:solaris2) - allow(plugin).to receive(:shell_out).with('pkg list -H').and_return(mock_shell_out(0, pkglist_output, '')) - allow(plugin).to receive(:shell_out).with('pkginfo -l').and_return(mock_shell_out(0, pkginfo_output, '')) + allow(plugin).to receive(:shell_out).with("pkg list -H").and_return(mock_shell_out(0, pkglist_output, "")) + allow(plugin).to receive(:shell_out).with("pkginfo -l").and_return(mock_shell_out(0, pkginfo_output, "")) plugin.run end - it 'calls pkg list -H' do + it "calls pkg list -H" do expect(plugin).to receive(:shell_out) - .with('pkg list -H') - .and_return(mock_shell_out(0, pkglist_output, '')) + .with("pkg list -H") + .and_return(mock_shell_out(0, pkglist_output, "")) plugin.run end - it 'calls pkginfo -l' do + it "calls pkginfo -l" do expect(plugin).to receive(:shell_out) - .with('pkginfo -l') - .and_return(mock_shell_out(0, pkginfo_output, '')) + .with("pkginfo -l") + .and_return(mock_shell_out(0, pkginfo_output, "")) plugin.run end - it 'gets ips packages with version' do - expect(plugin[:packages]['chef'][:version]).to eq('12.5.1') + it "gets ips packages with version" do + expect(plugin[:packages]["chef"][:version]).to eq("12.5.1") end - it 'gets ips packages with version and publisher' do - expect(plugin[:packages]['system/EMCpower'][:version]).to eq('6.0.0.1.0-3') - expect(plugin[:packages]['system/EMCpower'][:publisher]).to eq('emc.com') + it "gets ips packages with version and publisher" do + expect(plugin[:packages]["system/EMCpower"][:version]).to eq("6.0.0.1.0-3") + expect(plugin[:packages]["system/EMCpower"][:publisher]).to eq("emc.com") end - it 'gets sysv packages with version' do - expect(plugin[:packages]['chef'][:version]).to eq('12.5.1') + it "gets sysv packages with version" do + expect(plugin[:packages]["chef"][:version]).to eq("12.5.1") end - it 'gets sysv packages with version' do - expect(plugin[:packages]['mqm'][:version]).to eq('7.0.1.4') + it "gets sysv packages with version" do + expect(plugin[:packages]["mqm"][:version]).to eq("7.0.1.4") end end end diff --git a/spec/unit/plugins/passwd_spec.rb b/spec/unit/plugins/passwd_spec.rb index c12cddb4..b6559989 100644 --- a/spec/unit/plugins/passwd_spec.rb +++ b/spec/unit/plugins/passwd_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin etc", :unix_only do before(:each) do @@ -9,42 +9,42 @@ describe Ohai::System, "plugin etc", :unix_only do GroupEntry = Struct.new(:name, :gid, :mem) it "should include a list of all users" do - expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')). - and_yield(PasswdEntry.new('www', 800, 800, '/var/www', '/bin/false', 'Serving the web since 1970')) + expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH")). + and_yield(PasswdEntry.new("www", 800, 800, "/var/www", "/bin/false", "Serving the web since 1970")) @plugin.run - expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')) - expect(@plugin[:etc][:passwd]['www']).to eq(Mash.new(:shell => '/bin/false', :gecos => 'Serving the web since 1970', :gid => 800, :uid => 800, :dir => '/var/www')) + expect(@plugin[:etc][:passwd]["root"]).to eq(Mash.new(:shell => "/bin/zsh", :gecos => "BOFH", :gid => 1, :uid => 1, :dir => "/root")) + expect(@plugin[:etc][:passwd]["www"]).to eq(Mash.new(:shell => "/bin/false", :gecos => "Serving the web since 1970", :gid => 800, :uid => 800, :dir => "/var/www")) end it "should ignore duplicate users" do - expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, '/root', '/bin/zsh', 'BOFH')). - and_yield(PasswdEntry.new('root', 1, 1, '/', '/bin/false', 'I do not belong')) + expect(Etc).to receive(:passwd).and_yield(PasswdEntry.new("root", 1, 1, "/root", "/bin/zsh", "BOFH")). + and_yield(PasswdEntry.new("root", 1, 1, "/", "/bin/false", "I do not belong")) @plugin.run - expect(@plugin[:etc][:passwd]['root']).to eq(Mash.new(:shell => '/bin/zsh', :gecos => 'BOFH', :gid => 1, :uid => 1, :dir => '/root')) + expect(@plugin[:etc][:passwd]["root"]).to eq(Mash.new(:shell => "/bin/zsh", :gecos => "BOFH", :gid => 1, :uid => 1, :dir => "/root")) end it "should set the current user" do - expect(Process).to receive(:euid).and_return('31337') - expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new('chef', 31337, 31337, '/home/chef', '/bin/ksh', 'Julia Child')) + expect(Process).to receive(:euid).and_return("31337") + expect(Etc).to receive(:getpwuid).and_return(PasswdEntry.new("chef", 31337, 31337, "/home/chef", "/bin/ksh", "Julia Child")) @plugin.run - expect(@plugin[:current_user]).to eq('chef') + expect(@plugin[:current_user]).to eq("chef") end it "should set the available groups" do - expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, ['root', 'chef'])).and_yield(GroupEntry.new('www', 800, ['www', 'deploy'])) + expect(Etc).to receive(:group).and_yield(GroupEntry.new("admin", 100, %w{root chef})).and_yield(GroupEntry.new("www", 800, %w{www deploy})) @plugin.run - expect(@plugin[:etc][:group]['admin']).to eq(Mash.new(:gid => 100, :members => ['root', 'chef'])) - expect(@plugin[:etc][:group]['www']).to eq(Mash.new(:gid => 800, :members => ['www', 'deploy'])) + expect(@plugin[:etc][:group]["admin"]).to eq(Mash.new(:gid => 100, :members => %w{root chef})) + expect(@plugin[:etc][:group]["www"]).to eq(Mash.new(:gid => 800, :members => %w{www deploy})) end if "".respond_to?(:force_encoding) it "sets the encoding of strings to the default external encoding" do - fields = ["root", 1, 1, '/root', '/bin/zsh', 'BOFH'] - fields.each {|f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) } + fields = ["root", 1, 1, "/root", "/bin/zsh", "BOFH"] + fields.each { |f| f.force_encoding(Encoding::ASCII_8BIT) if f.respond_to?(:force_encoding) } allow(Etc).to receive(:passwd).and_yield(PasswdEntry.new(*fields)) @plugin.run - root = @plugin[:etc][:passwd]['root'] - expect(root['gecos'].encoding).to eq(Encoding.default_external) + root = @plugin[:etc][:passwd]["root"] + expect(root["gecos"].encoding).to eq(Encoding.default_external) end end end diff --git a/spec/unit/plugins/perl_spec.rb b/spec/unit/plugins/perl_spec.rb index b7eb0a7e..331ea9a4 100644 --- a/spec/unit/plugins/perl_spec.rb +++ b/spec/unit/plugins/perl_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin perl" do before(:each) do diff --git a/spec/unit/plugins/php_spec.rb b/spec/unit/plugins/php_spec.rb index ab735c42..4df8aae1 100644 --- a/spec/unit/plugins/php_spec.rb +++ b/spec/unit/plugins/php_spec.rb @@ -18,14 +18,14 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin php" do before(:each) do @plugin = get_plugin("php") @plugin[:languages] = Mash.new - @stdout = <<-OUT + @stdout = <<-OUT PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies @@ -55,7 +55,7 @@ OUT end it "should parse builddate even if it's suhosin patched" do - @stdout = <<-OUT + @stdout = <<-OUT PHP 5.3.27 with Suhosin-Patch (cli) (built: Aug 30 2013 04:30:30) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies @@ -66,7 +66,7 @@ OUT end it "should not set zend_optcache_version if not compiled with opcache" do - @stdout = <<-OUT + @stdout = <<-OUT PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies diff --git a/spec/unit/plugins/platform_spec.rb b/spec/unit/plugins/platform_spec.rb index cbc98076..7e841c3f 100644 --- a/spec/unit/plugins/platform_spec.rb +++ b/spec/unit/plugins/platform_spec.rb @@ -16,15 +16,14 @@ # limitations under the License. # - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin platform" do before(:each) do @plugin = get_plugin("platform") allow(@plugin).to receive(:collect_os).and_return(:default) - @plugin[:os] = 'monkey' - @plugin[:os_version] = 'poop' + @plugin[:os] = "monkey" + @plugin[:os_version] = "poop" end it "should set the platform and platform family to the os if it was not set earlier" do @@ -34,20 +33,20 @@ describe Ohai::System, "plugin platform" do end it "should not set the platform to the os if it was set earlier" do - @plugin[:platform] = 'lars' + @plugin[:platform] = "lars" @plugin.run expect(@plugin[:platform]).to eql("lars") end it "should set the platform_family to the platform if platform was set earlier but not platform_family" do - @plugin[:platform] = 'lars' - @plugin[:platform_family] = 'jack' + @plugin[:platform] = "lars" + @plugin[:platform_family] = "jack" @plugin.run expect(@plugin[:platform_family]).to eql("jack") end it "should not set the platform_family if the platform_family was set earlier." do - @plugin[:platform] = 'lars' + @plugin[:platform] = "lars" @plugin.run expect(@plugin[:platform]).to eql("lars") expect(@plugin[:platform_family]).to eql("lars") @@ -59,7 +58,7 @@ describe Ohai::System, "plugin platform" do end it "should not set the platform to the os if it was set earlier" do - @plugin[:platform_version] = 'ulrich' + @plugin[:platform_version] = "ulrich" @plugin.run expect(@plugin[:platform_version]).to eql("ulrich") end diff --git a/spec/unit/plugins/powershell_spec.rb b/spec/unit/plugins/powershell_spec.rb index fd7a7829..ae49698c 100644 --- a/spec/unit/plugins/powershell_spec.rb +++ b/spec/unit/plugins/powershell_spec.rb @@ -15,11 +15,11 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin powershell" do before do - stub_const('::RbConfig::CONFIG', {'host_os' => 'windows'}) + stub_const("::RbConfig::CONFIG", { "host_os" => "windows" }) end before(:each) do @@ -50,7 +50,7 @@ END expect(@plugin.languages[:powershell][:serialization_version]).to eql("1.1.0.1") expect(@plugin.languages[:powershell][:clr_version]).to eql("4.0.30319.34014") expect(@plugin.languages[:powershell][:build_version]).to eql("6.3.9600.16394") - expect(@plugin.languages[:powershell][:compatible_versions]).to eql(['1.0', '2.0', '3.0', '4.0']) + expect(@plugin.languages[:powershell][:compatible_versions]).to eql(["1.0", "2.0", "3.0", "4.0"]) expect(@plugin.languages[:powershell][:remoting_protocol_version]).to eql("2.2") end diff --git a/spec/unit/plugins/python_spec.rb b/spec/unit/plugins/python_spec.rb index 81bfe90a..87fd5c14 100644 --- a/spec/unit/plugins/python_spec.rb +++ b/spec/unit/plugins/python_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin python" do let(:stdout) { "2.5.2 (r252:60911, Jan 4 2009, 17:40:26)\n[GCC 4.3.2]\n" } diff --git a/spec/unit/plugins/rackspace_spec.rb b/spec/unit/plugins/rackspace_spec.rb index e1c6f13a..370abe5c 100644 --- a/spec/unit/plugins/rackspace_spec.rb +++ b/spec/unit/plugins/rackspace_spec.rb @@ -15,53 +15,53 @@ # limitations under the License. # -require 'resolv' +require "resolv" -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") describe Ohai::System, "plugin rackspace" do before(:each) do allow(Resolv).to receive(:getname).and_return("1.2.3.4") @plugin = get_plugin("rackspace") @plugin[:hostname] = "katie" - @plugin[:network] = {:interfaces => {:eth0 => {"addresses"=> { - "1.2.3.4"=> { - "broadcast"=> "67.23.20.255", - "netmask"=> "255.255.255.0", - "family"=> "inet" + @plugin[:network] = { :interfaces => { :eth0 => { "addresses" => { + "1.2.3.4" => { + "broadcast" => "67.23.20.255", + "netmask" => "255.255.255.0", + "family" => "inet", }, - "2a00:1a48:7805:111:e875:efaf:ff08:75"=> { - "family"=> "inet6", - "prefixlen"=> "64", - "scope"=> "Global" + "2a00:1a48:7805:111:e875:efaf:ff08:75" => { + "family" => "inet6", + "prefixlen" => "64", + "scope" => "Global", }, - "fe80::4240:95ff:fe47:6eed"=> { - "scope"=> "Link", - "prefixlen"=> "64", - "family"=> "inet6" + "fe80::4240:95ff:fe47:6eed" => { + "scope" => "Link", + "prefixlen" => "64", + "family" => "inet6", }, - "40:40:95:47:6E:ED"=> { - "family"=> "lladdr" - } - }} + "40:40:95:47:6E:ED" => { + "family" => "lladdr" + }, + } } } } - @plugin[:network][:interfaces][:eth1] = {:addresses => { - "fe80::4240:f5ff:feab:2836" => { - "scope"=> "Link", - "prefixlen"=> "64", - "family"=> "inet6" - }, - "5.6.7.8"=> { - "broadcast"=> "10.176.191.255", - "netmask"=> "255.255.224.0", - "family"=> "inet" - }, - "40:40:F5:AB:28:36" => { - "family"=> "lladdr" - } - }} + @plugin[:network][:interfaces][:eth1] = { :addresses => { + "fe80::4240:f5ff:feab:2836" => { + "scope" => "Link", + "prefixlen" => "64", + "family" => "inet6", + }, + "5.6.7.8" => { + "broadcast" => "10.176.191.255", + "netmask" => "255.255.224.0", + "family" => "inet", + }, + "40:40:F5:AB:28:36" => { + "family" => "lladdr" + }, + } } # In olden days we could detect rackspace by a -rscloud suffix on the kernel # This is here to make #has_rackspace_kernel? fail until we remove that check @@ -72,7 +72,7 @@ describe Ohai::System, "plugin rackspace" do allow(@plugin).to receive(:shell_out).and_return(mock_shell_out(1, "", "")) end - shared_examples_for "!rackspace" do + shared_examples_for "!rackspace" do it "should NOT create rackspace" do @plugin.run expect(@plugin[:rackspace]).to be_nil @@ -119,7 +119,7 @@ describe Ohai::System, "plugin rackspace" do expect(@plugin[:rackspace][:public_ipv4]).to eq("1.2.3.4") expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8") expect(@plugin[:rackspace][:public_ipv6]).to eq("2a00:1a48:7805:111:e875:efaf:ff08:75") - expect(@plugin[:rackspace][:local_hostname]).to eq('katie') + expect(@plugin[:rackspace][:local_hostname]).to eq("katie") expect(@plugin[:rackspace][:public_hostname]).to eq("1.2.3.4") end @@ -149,18 +149,18 @@ OUT before(:each) do allow(Resolv).to receive(:getname).and_raise(Resolv::ResolvError) - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') - allow(File).to receive(:exist?).with('/etc/resolv.conf').and_return(true) - allow(File).to receive(:read).with('/etc/resolv.conf').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("") + allow(File).to receive(:exist?).with("/etc/resolv.conf").and_return(true) + allow(File).to receive(:read).with("/etc/resolv.conf").and_return("") end - describe 'with no public interfaces (empty eth0)' do + describe "with no public interfaces (empty eth0)" do before do # unset public (eth0) addresses - @plugin[:network][:interfaces][:eth0]['addresses'] = {} + @plugin[:network][:interfaces][:eth0]["addresses"] = {} end it "should have all required attributes" do @@ -181,7 +181,7 @@ OUT @plugin.run expect(@plugin[:rackspace][:private_ip]).to eq("5.6.7.8") expect(@plugin[:rackspace][:local_ipv4]).to eq("5.6.7.8") - expect(@plugin[:rackspace][:local_hostname]).to eq('katie') + expect(@plugin[:rackspace][:local_hostname]).to eq("katie") end end end @@ -190,7 +190,7 @@ OUT it_should_behave_like "!rackspace" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) end end @@ -199,12 +199,12 @@ OUT it_should_behave_like "!rackspace" before(:each) do - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("") - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(false) + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(false) allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(false) end end @@ -234,10 +234,10 @@ OUT stdout = '{"label": "public", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}' allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" )) - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("") end it "should not have private_networks object" do @@ -248,30 +248,30 @@ OUT describe "has private networks" do before do - @plugin[:network][:interfaces][:eth2] = {:addresses => { + @plugin[:network][:interfaces][:eth2] = { :addresses => { "fe80::be76:4eff:fe20:422b" => { - "scope"=> "Link", - "prefixlen"=> "64", - "family"=> "inet6" + "scope" => "Link", + "prefixlen" => "64", + "family" => "inet6", }, - "9.10.11.12"=> { - "broadcast"=> "9.10.11.255", - "netmask"=> "255.255.255.0", - "family"=> "inet" + "9.10.11.12" => { + "broadcast" => "9.10.11.255", + "netmask" => "255.255.255.0", + "family" => "inet", }, "BC:76:4E:20:42:2B" => { - "family"=> "lladdr" - } - }} + "family" => "lladdr" + }, + } } stdout = 'BC764E20422B = "{"label": "private-network"}"\n' allow(@plugin).to receive(:shell_out).with("xenstore-ls vm-data/networking").and_return(mock_shell_out(0, stdout, "" )) stdout = '{"label": "private-network", "broadcast": "9.10.11.255", "ips": [{"ip": "9.10.11.12", "netmask": "255.255.255.0", "enabled": "1", "gateway": null}], "mac": "BC:76:4E:20:42:2B", "dns": ["69.20.0.164", "69.20.0.196"], "gateway": null}' allow(@plugin).to receive(:shell_out).with("xenstore-read vm-data/networking/BC764E20422B").and_return(mock_shell_out(0, stdout, "" )) - allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('') + allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true) + allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("") allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true) - allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('') + allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("") end it "should private_networks object" do @@ -288,6 +288,4 @@ OUT end - - end diff --git a/spec/unit/plugins/root_group_spec.rb b/spec/unit/plugins/root_group_spec.rb index 13d04b41..67ee4c11 100644 --- a/spec/unit/plugins/root_group_spec.rb +++ b/spec/unit/plugins/root_group_spec.rb @@ -16,73 +16,73 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') -require File.expand_path(File.dirname(__FILE__) + '/../../../lib/ohai/util/win32/group_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") +require File.expand_path(File.dirname(__FILE__) + "/../../../lib/ohai/util/win32/group_helper.rb") -describe Ohai::System, 'root_group' do +describe Ohai::System, "root_group" do before(:each) do @plugin = get_plugin("root_group") end - describe 'unix platform', :unix_only do + describe "unix platform", :unix_only do before(:each) do # this is deeply intertwingled. unfortunately, the law of demeter # apparently didn't apply to this api. we're just trying to fake # Etc.getgrgid(Etc.getpwnam('root').gid).name @pwnam = Object.new allow(@pwnam).to receive(:gid).and_return(0) - allow(Etc).to receive(:getpwnam).with('root').and_return(@pwnam) + allow(Etc).to receive(:getpwnam).with("root").and_return(@pwnam) @grgid = Object.new allow(Etc).to receive(:getgrgid).and_return(@grgid) end - describe 'with wheel group' do + describe "with wheel group" do before(:each) do - allow(@grgid).to receive(:name).and_return('wheel') + allow(@grgid).to receive(:name).and_return("wheel") end - it 'should have a root_group of wheel' do + it "should have a root_group of wheel" do @plugin.run - expect(@plugin[:root_group]).to eq('wheel') + expect(@plugin[:root_group]).to eq("wheel") end end - describe 'with root group' do + describe "with root group" do before(:each) do - allow(@grgid).to receive(:name).and_return('root') + allow(@grgid).to receive(:name).and_return("root") end - it 'should have a root_group of root' do + it "should have a root_group of root" do @plugin.run - expect(@plugin[:root_group]).to eq('root') + expect(@plugin[:root_group]).to eq("root") end end - describe 'platform hpux with sys group' do + describe "platform hpux with sys group" do before(:each) do allow(@pwnam).to receive(:gid).and_return(3) - allow(@grgid).to receive(:name).and_return('sys') + allow(@grgid).to receive(:name).and_return("sys") end - it 'should have a root_group of sys' do + it "should have a root_group of sys" do @plugin.run - expect(@plugin[:root_group]).to eq('sys') + expect(@plugin[:root_group]).to eq("sys") end end - describe 'platform aix with system group' do + describe "platform aix with system group" do before(:each) do - allow(@grgid).to receive(:name).and_return('system') + allow(@grgid).to receive(:name).and_return("system") end - it 'should have a root_group of system' do + it "should have a root_group of system" do @plugin.run - expect(@plugin[:root_group]).to eq('system') + expect(@plugin[:root_group]).to eq("system") end end end - describe 'windows platform' do - it 'should return the group administrators' do - stub_const('::RbConfig::CONFIG', { 'host_os' => 'windows'} ) - expect(Ohai::Util::Win32::GroupHelper).to receive(:windows_root_group_name).and_return('administrators') + describe "windows platform" do + it "should return the group administrators" do + stub_const("::RbConfig::CONFIG", { "host_os" => "windows" } ) + expect(Ohai::Util::Win32::GroupHelper).to receive(:windows_root_group_name).and_return("administrators") @plugin.run - expect(@plugin[:root_group]).to eq('administrators') + expect(@plugin[:root_group]).to eq("administrators") end end end diff --git a/spec/unit/plugins/ruby_spec.rb b/spec/unit/plugins/ruby_spec.rb index 2319432a..c57755f5 100644 --- a/spec/unit/plugins/ruby_spec.rb +++ b/spec/unit/plugins/ruby_spec.rb @@ -16,10 +16,9 @@ # limitations under the License. # +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') - -ruby_bin = File.join(::RbConfig::CONFIG['bindir'], ::RbConfig::CONFIG['ruby_install_name']) +ruby_bin = File.join(::RbConfig::CONFIG["bindir"], ::RbConfig::CONFIG["ruby_install_name"]) describe Ohai::System, "plugin ruby" do @@ -39,18 +38,18 @@ describe Ohai::System, "plugin ruby" do :platform => RUBY_PLATFORM, :version => RUBY_VERSION, :release_date => RUBY_RELEASE_DATE, - :target => ::RbConfig::CONFIG['target'], - :target_cpu => ::RbConfig::CONFIG['target_cpu'], - :target_vendor => ::RbConfig::CONFIG['target_vendor'], - :target_os => ::RbConfig::CONFIG['target_os'], - :host => ::RbConfig::CONFIG['host'], - :host_cpu => ::RbConfig::CONFIG['host_cpu'], - :host_os => ::RbConfig::CONFIG['host_os'], - :host_vendor => ::RbConfig::CONFIG['host_vendor'], - :gems_dir => %x{#{ruby_bin} #{::RbConfig::CONFIG['bindir']}/gem env gemdir}.chomp, - :gem_bin => [ ::Gem.default_exec_format % 'gem', 'gem' ].map{|bin| "#{::RbConfig::CONFIG['bindir']}/#{bin}" - }.find{|bin| ::File.exists? bin}, - :ruby_bin => ruby_bin + :target => ::RbConfig::CONFIG["target"], + :target_cpu => ::RbConfig::CONFIG["target_cpu"], + :target_vendor => ::RbConfig::CONFIG["target_vendor"], + :target_os => ::RbConfig::CONFIG["target_os"], + :host => ::RbConfig::CONFIG["host"], + :host_cpu => ::RbConfig::CONFIG["host_cpu"], + :host_os => ::RbConfig::CONFIG["host_os"], + :host_vendor => ::RbConfig::CONFIG["host_vendor"], + :gems_dir => `#{ruby_bin} #{::RbConfig::CONFIG["bindir"]}/gem env gemdir`.chomp, + :gem_bin => [ ::Gem.default_exec_format % "gem", "gem" ].map {|bin| "#{::RbConfig::CONFIG['bindir']}/#{bin}" + }.find { |bin| ::File.exists? bin }, + :ruby_bin => ruby_bin, }.each do |attribute, value| it "should have #{attribute} set to #{value.inspect}" do expect(@ruby_ohai_data[attribute]).to eql(value) diff --git a/spec/unit/plugins/rust_spec.rb b/spec/unit/plugins/rust_spec.rb index aa4e495f..daa45d48 100644 --- a/spec/unit/plugins/rust_spec.rb +++ b/spec/unit/plugins/rust_spec.rb @@ -14,10 +14,10 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "plugin rust" do - let(:stdout) {"rustc 1.0.0-nightly (29bd9a06e 2015-01-20 23:03:09 +0000)"} + let(:stdout) { "rustc 1.0.0-nightly (29bd9a06e 2015-01-20 23:03:09 +0000)" } let (:plugin) do plugin = get_plugin("rust") plugin[:languages] = Mash.new diff --git a/spec/unit/plugins/sigar/network_route_spec.rb b/spec/unit/plugins/sigar/network_route_spec.rb index 4543f7b7..b3b2ec4d 100644 --- a/spec/unit/plugins/sigar/network_route_spec.rb +++ b/spec/unit/plugins/sigar/network_route_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") sigar_available = begin - require 'sigar' + require "sigar" true rescue LoadError false end -require 'ohai' +require "ohai" describe Ohai::System, "Sigar network route plugin" do @@ -36,18 +36,18 @@ describe Ohai::System, "Sigar network route plugin" do @plugin = get_plugin("sigar/network", @ohai) allow(@plugin).to receive(:collect_os).and_return(:sigar) @sigar = double("Sigar") - @net_info_conf={ + @net_info_conf = { :default_gateway => "192.168.1.254", :default_gateway_interface => "eth0", :primary_dns => "192.168.1.254", :secondary_dns => "8.8.8.8", - :host_name => "localhost" + :host_name => "localhost", } - net_info=double("Sigar::NetInfo") - @net_info_conf.each_pair do |k,v| + net_info = double("Sigar::NetInfo") + @net_info_conf.each_pair do |k, v| allow(net_info).to receive(k).and_return(v) end - @net_route_conf={ + @net_route_conf = { :destination => "192.168.1.0", :gateway => "0.0.0.0", :mask => "255.255.255.0", @@ -58,13 +58,13 @@ describe Ohai::System, "Sigar network route plugin" do :mtu => 0, :window => 0, :irtt => 0, - :ifname => "eth0" + :ifname => "eth0", } - net_route=double("Sigar::NetRoute") - @net_route_conf.each_pair do |k,v| + net_route = double("Sigar::NetRoute") + @net_route_conf.each_pair do |k, v| allow(net_route).to receive(k).and_return(v) end - @net_interface_conf={ + @net_interface_conf = { :flags => 2115, :destination => "192.168.1.1", :mtu => 1500, @@ -77,39 +77,39 @@ describe Ohai::System, "Sigar network route plugin" do :tx_queue_len => 1000, :prefix6_length => 0, } - net_conf=double("Sigar::NetConf") - @net_interface_conf.each_pair do |k,v| + net_conf = double("Sigar::NetConf") + @net_interface_conf.each_pair do |k, v| allow(net_conf).to receive(k).and_return(v) end - @net_interface_stat={ - :rx_bytes=>1369035618, - :rx_dropped=>0, - :rx_errors=>0, - :rx_frame=>0, - :rx_overruns=>0, - :rx_packets=>7271669, - :speed=>-1, - :tx_bytes=>3482843666, - :tx_carrier=>0, - :tx_collisions=>0, - :tx_dropped=>0, - :tx_errors=>0, - :tx_overruns=>0, - :tx_packets=>4392794 + @net_interface_stat = { + :rx_bytes => 1369035618, + :rx_dropped => 0, + :rx_errors => 0, + :rx_frame => 0, + :rx_overruns => 0, + :rx_packets => 7271669, + :speed => -1, + :tx_bytes => 3482843666, + :tx_carrier => 0, + :tx_collisions => 0, + :tx_dropped => 0, + :tx_errors => 0, + :tx_overruns => 0, + :tx_packets => 4392794, } - net_stat=double("Sigar::NetStat") - @net_interface_stat.each_pair do |k,v| + net_stat = double("Sigar::NetStat") + @net_interface_stat.each_pair do |k, v| allow(net_stat).to receive(k).and_return(v) end - @net_arp_conf={ + @net_arp_conf = { :address => "192.168.1.5", :flags => 2, :hwaddr => "00:15:62:96:01:D0", :ifname => "eth0", :type => "ether", } - net_arp=double("Sigar::NetArp") - @net_arp_conf.each_pair do |k,v| + net_arp = double("Sigar::NetArp") + @net_arp_conf.each_pair do |k, v| allow(net_arp).to receive(k).and_return(v) end allow(@sigar).to receive(:fqdn).and_return("localhost.localdomain") @@ -131,10 +131,10 @@ describe Ohai::System, "Sigar network route plugin" do end it "should set the route details" do - @net_route_conf.each_pair do |k,v| + @net_route_conf.each_pair do |k, v| # Work around the above doubleing of net_route_list skipping the call to flags() if k == :flags - v="U" + v = "U" @plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"][k] = v end expect(@plugin[:network][:interfaces][:eth0][:route]["192.168.1.0"]).to have_key(k) diff --git a/spec/unit/plugins/softlayer_spec.rb b/spec/unit/plugins/softlayer_spec.rb index 0d0c45ae..a8370962 100644 --- a/spec/unit/plugins/softlayer_spec.rb +++ b/spec/unit/plugins/softlayer_spec.rb @@ -17,42 +17,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb") -describe Ohai::System, 'plugin softlayer' do +describe Ohai::System, "plugin softlayer" do let(:plugin) { get_plugin("softlayer") } it "not create softlayer if hint file doesn't exists" do - allow(@plugin).to receive(:hint?).with('softlayer').and_return(false) + allow(@plugin).to receive(:hint?).with("softlayer").and_return(false) plugin.run expect(plugin[:softlayer]).to be_nil end it "do not create node if fetch_metadata raise an error" do - allow(plugin).to receive(:hint?).with('softlayer').and_return(false) + allow(plugin).to receive(:hint?).with("softlayer").and_return(false) allow(plugin).to receive(:fetch_metadata).and_raise(StandardError.new("TEST")) plugin.run expect(plugin[:softlayer]).to be_nil end it "create empty node if fetch_metadata return empty hash" do - allow(plugin).to receive(:hint?).with('softlayer').and_return(true) + allow(plugin).to receive(:hint?).with("softlayer").and_return(true) allow(plugin).to receive(:fetch_metadata).and_return({}) plugin.run expect(plugin[:softlayer]).to eq({}) end it "create empty node if fetch_metadata return hash with nil values" do - metadata = { 'local_ipv4' => nil, 'public_ipv4' => nil, 'public_fqdn' => nil} - allow(plugin).to receive(:hint?).with('softlayer').and_return(true) + metadata = { "local_ipv4" => nil, "public_ipv4" => nil, "public_fqdn" => nil } + allow(plugin).to receive(:hint?).with("softlayer").and_return(true) allow(plugin).to receive(:fetch_metadata).and_return(metadata) plugin.run expect(plugin[:softlayer]).to eq(metadata) end - it 'populate softlayer node with required attributes' do - metadata = { 'local_ipv4' => '192.168.0.1', 'public_ipv4' => '8.8.8.8', 'public_fqdn' => 'abc1234.public.com'} - allow(plugin).to receive(:hint?).with('softlayer').and_return(true) + it "populate softlayer node with required attributes" do + metadata = { "local_ipv4" => "192.168.0.1", "public_ipv4" => "8.8.8.8", "public_fqdn" => "abc1234.public.com" } + allow(plugin).to receive(:hint?).with("softlayer").and_return(true) allow(plugin).to receive(:fetch_metadata).and_return(metadata) plugin.run expect(plugin[:softlayer]).to eq(metadata) diff --git a/spec/unit/plugins/solaris2/cpu_spec.rb b/spec/unit/plugins/solaris2/cpu_spec.rb index e4b1d891..c183b796 100644 --- a/spec/unit/plugins/solaris2/cpu_spec.rb +++ b/spec/unit/plugins/solaris2/cpu_spec.rb @@ -14,14 +14,14 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X cpu plugin" do before(:each) do @plugin = get_plugin("solaris2/cpu") allow(@plugin).to receive(:collect_os).and_return("solaris2") end - + describe "on x86 processors" do before(:each) do kstatinfo_output = <<-END @@ -91,7 +91,7 @@ cpu_info:2:cpu_info2:current_cstate 0 cpu_info:2:cpu_info2:family 12 cpu_info:2:cpu_info2:fpu_type i387 compatible cpu_info:2:cpu_info2:implementation x86 (chipid 0x1 GenuineIntel family 6 model 26 step 5 clock 2926 MHz) -cpu_info:2:cpu_info2:model 93 +cpu_info:2:cpu_info2:model 93 cpu_info:2:cpu_info2:ncore_per_chip 4 cpu_info:2:cpu_info2:ncpu_per_chip 8 cpu_info:2:cpu_info2:pg_id 7 @@ -247,7 +247,7 @@ cpu_info:8:cpu_info8:current_cstate 1 cpu_info:8:cpu_info8:family 12 cpu_info:8:cpu_info8:fpu_type i387 compatible cpu_info:8:cpu_info8:implementation x86 (chipid 0x1 GenuineIntel family 6 model 26 step 5 clock 2926 MHz) -cpu_info:8:cpu_info8:model 93 +cpu_info:8:cpu_info8:model 93 cpu_info:8:cpu_info8:ncore_per_chip 4 cpu_info:8:cpu_info8:ncpu_per_chip 8 cpu_info:8:cpu_info8:pg_id 1 @@ -461,14 +461,14 @@ END it "should get the total number of online cores" do expect(@plugin["cpu"]["cpustates"]["on-line"]).to eql (8) end - + it "should get the total number of offline cores" do expect(@plugin["cpu"]["cpustates"]["off-line"]).to eql (8) end - + describe "per-cpu information" do it "should include processor vendor_ids" do - # CPU Socket 0 + # CPU Socket 0 expect(@plugin["cpu"]["15"]["vendor_id"]).to eql("GenuineIntel") expect(@plugin["cpu"]["13"]["vendor_id"]).to eql("GenuineIntel") expect(@plugin["cpu"]["11"]["vendor_id"]).to eql("GenuineIntel") @@ -566,7 +566,7 @@ END expect(@plugin["cpu"]["4"]["stepping"]).to eql("9") expect(@plugin["cpu"]["2"]["stepping"]).to eql("9") expect(@plugin["cpu"]["0"]["stepping"]).to eql("9") - + end it "should include processor model names" do @@ -627,8 +627,7 @@ END end end end - - + describe "on sparc processors" do before(:each) do kstatinfo_output = <<-END @@ -2812,7 +2811,7 @@ END allow(@plugin).to receive(:shell_out).with("kstat -p cpu_info").and_return(mock_shell_out(0, kstatinfo_output, "")) @plugin.run end - + it "should get the total virtual processor count" do expect(@plugin["cpu"]["total"]).to eql(128) end @@ -2820,11 +2819,11 @@ END it "should get the total processor count" do expect(@plugin["cpu"]["real"]).to eql(1) end - + it "should get the total core count" do expect(@plugin["cpu"]["cores"]).to eql(16) end - + it "should get the number of threads per core" do expect(@plugin["cpu"]["corethreads"]).to eql(8) end @@ -2832,11 +2831,11 @@ END it "should get the total number of online cores" do expect(@plugin["cpu"]["cpustates"]["on-line"]).to eql(124) end - + it "should get the total number of offline cores" do expect(@plugin["cpu"]["cpustates"]["off-line"]).to eql(4) end - + describe "per-cpu information" do it "should include processor model names" do expect(@plugin["cpu"]["0"]["model_name"]).to eql("SPARC-T3") @@ -2890,7 +2889,7 @@ END expect(@plugin["cpu"]["120"]["core_id"]).to eql("1131") end - it "should include processor architecture" do + it "should include processor architecture" do expect(@plugin["cpu"]["0"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["1"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["2"]["arch"]).to eql("sparcv9") @@ -2899,9 +2898,9 @@ END expect(@plugin["cpu"]["125"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["126"]["arch"]).to eql("sparcv9") expect(@plugin["cpu"]["127"]["arch"]).to eql("sparcv9") - end + end - it "should include processor FPU type" do + it "should include processor FPU type" do expect(@plugin["cpu"]["0"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["1"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["2"]["fpu_type"]).to eql("sparcv9") @@ -2910,9 +2909,9 @@ END expect(@plugin["cpu"]["125"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["126"]["fpu_type"]).to eql("sparcv9") expect(@plugin["cpu"]["127"]["fpu_type"]).to eql("sparcv9") - end + end - it "should include processor state" do + it "should include processor state" do expect(@plugin["cpu"]["0"]["state"]).to eql("on-line") expect(@plugin["cpu"]["1"]["state"]).to eql("on-line") expect(@plugin["cpu"]["2"]["state"]).to eql("on-line") @@ -2921,7 +2920,7 @@ END expect(@plugin["cpu"]["125"]["state"]).to eql("off-line") expect(@plugin["cpu"]["126"]["state"]).to eql("off-line") expect(@plugin["cpu"]["127"]["state"]).to eql("off-line") - end + end end end end diff --git a/spec/unit/plugins/solaris2/dmi_spec.rb b/spec/unit/plugins/solaris2/dmi_spec.rb index add22ec1..261c4431 100644 --- a/spec/unit/plugins/solaris2/dmi_spec.rb +++ b/spec/unit/plugins/solaris2/dmi_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") SOLARIS_DMI_OUT = <<-EOS ID SIZE TYPE @@ -127,16 +127,16 @@ describe Ohai::System, "Solaris2.X DMI plugin" do { bios: { vendor: "American Megatrends Inc.", - release_date: "08/26/2014" + release_date: "08/26/2014", }, system: { manufacturer: "System manufacturer", - product: "System Product Name" + product: "System Product Name", }, chassis: { lock_present: "N", - asset_tag: "PCS" - } + asset_tag: "PCS", + }, }.each do |id, data| data.each do |attribute, value| it "should have [:dmi][:#{id}][:#{attribute}] set" do @@ -151,4 +151,3 @@ describe Ohai::System, "Solaris2.X DMI plugin" do expect(@plugin[:dmi]).not_to have_key(:on_board_devices) end end - diff --git a/spec/unit/plugins/solaris2/filesystem.rb b/spec/unit/plugins/solaris2/filesystem.rb index f8a8c29b..1ed36cf7 100644 --- a/spec/unit/plugins/solaris2/filesystem.rb +++ b/spec/unit/plugins/solaris2/filesystem.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require_relative '../../../spec_helper' +require_relative "../../../spec_helper" describe Ohai::System, "Solaris2.X filesystem plugin" do let(:plugin) { get_plugin("solaris2/filesystem") } @@ -68,15 +68,15 @@ describe Ohai::System, "Solaris2.X filesystem plugin" do context "as a String" do include_examples "configured zfs properties" do - let(:zfs_properties) { 'mountpoint,creation,available,used' } - let(:expected_cmd) { 'mountpoint,creation,available,used' } + let(:zfs_properties) { "mountpoint,creation,available,used" } + let(:expected_cmd) { "mountpoint,creation,available,used" } end end context "as an Array" do include_examples "configured zfs properties" do - let(:zfs_properties) { ['mountpoint', 'creation', 'available', 'used'] } - let(:expected_cmd) { 'mountpoint,creation,available,used' } + let(:zfs_properties) { %w{mountpoint creation available used} } + let(:expected_cmd) { "mountpoint,creation,available,used" } end end end diff --git a/spec/unit/plugins/solaris2/hostname_spec.rb b/spec/unit/plugins/solaris2/hostname_spec.rb index 00c2936c..6b793abe 100644 --- a/spec/unit/plugins/solaris2/hostname_spec.rb +++ b/spec/unit/plugins/solaris2/hostname_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X hostname plugin" do before(:each) do diff --git a/spec/unit/plugins/solaris2/kernel_spec.rb b/spec/unit/plugins/solaris2/kernel_spec.rb index 729b20a3..ad6f9768 100644 --- a/spec/unit/plugins/solaris2/kernel_spec.rb +++ b/spec/unit/plugins/solaris2/kernel_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X kernel plugin" do # NOTE: Solaris will report the same module loaded multiple times # with the same ID, Loadaddr, etc. and only the info column different # ignoring it, and removing the data from this fixture. - MODINFO=<<-TOOMUCH + MODINFO = <<-TOOMUCH Id Loadaddr Size Info Rev Module Name 6 1180000 4623 1 1 specfs (filesystem for specfs) 8 1185df0 38c4 1 1 TS (time sharing sched class) @@ -151,7 +151,7 @@ describe Ohai::System, "Solaris2.X kernel plugin" do # Teh daterz # Id Loadaddr Size Info Rev Module Name # 6 1180000 4623 1 1 specfs (filesystem for specfs) - teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs"} + teh_daterz = { "id" => 6, "loadaddr" => "1180000", "size" => 17955, "description" => "filesystem for specfs" } expect(@plugin[:kernel][:modules].keys).to include("specfs") expect(@plugin[:kernel][:modules].keys).not_to include("Module") expect(@plugin[:kernel][:modules]["specfs"]).to eq(teh_daterz) diff --git a/spec/unit/plugins/solaris2/memory_spec.rb b/spec/unit/plugins/solaris2/memory_spec.rb index f2ef882b..101dcd3d 100644 --- a/spec/unit/plugins/solaris2/memory_spec.rb +++ b/spec/unit/plugins/solaris2/memory_spec.rb @@ -14,7 +14,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X memory plugin" do before(:each) do @@ -22,22 +22,22 @@ describe Ohai::System, "Solaris2.X memory plugin" do allow(@plugin).to receive(:collect_os).and_return("solaris2") allow(@plugin).to receive(:shell_out).with("prtconf | grep Memory").and_return(mock_shell_out(0, "Memory size: 8194 Megabytes\n", "")) @swap_s = "total: 112230656k bytes allocated + 357865576k reserved = 470096232k used, 47057688k available\n" - allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0,@swap_s, "")) + allow(@plugin).to receive(:shell_out).with("swap -s").and_return(mock_shell_out(0, @swap_s, "")) end it "should get the total memory" do @plugin.run expect(@plugin[:memory][:total]).to eql("#{8194 * 1024}kB") end - + it "should get total swap" do @plugin.run expect(@plugin[:memory][:swap][:total]).to eql("#{(470096232 + 47057688)}kB" ) end - + it "should get free swap" do @plugin.run expect(@plugin[:memory][:swap][:free]).to eql("47057688kB") end - + end diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb index 98ae0c11..5283b068 100644 --- a/spec/unit/plugins/solaris2/network_spec.rb +++ b/spec/unit/plugins/solaris2/network_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris2.X network plugin" do @@ -129,23 +129,23 @@ ROUTE_GET end it "completes the run" do - expect(@plugin['network']).not_to be_nil + expect(@plugin["network"]).not_to be_nil end it "detects the interfaces" do - expect(@plugin['network']['interfaces'].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3","net0", "qfe1"]) + expect(@plugin["network"]["interfaces"].keys.sort).to eq(["e1000g0:3", "e1000g2:1", "eri0", "ip.tun0", "ip.tun0:1", "lo0", "lo0:3", "net0", "qfe1"]) end it "detects the ip addresses of the interfaces" do - expect(@plugin['network']['interfaces']['e1000g0:3']['addresses'].keys).to include('72.2.115.28') + expect(@plugin["network"]["interfaces"]["e1000g0:3"]["addresses"].keys).to include("72.2.115.28") end it "detects the encapsulation type of the interfaces" do - expect(@plugin['network']['interfaces']['e1000g0:3']['encapsulation']).to eq('Ethernet') + expect(@plugin["network"]["interfaces"]["e1000g0:3"]["encapsulation"]).to eq("Ethernet") end it "detects the L3PROTECT network flag" do - expect(@plugin['network']['interfaces']['net0']['flags']).to include('L3PROTECT') + expect(@plugin["network"]["interfaces"]["net0"]["flags"]).to include("L3PROTECT") end end @@ -159,8 +159,7 @@ ROUTE_GET end it "finds the default interface by asking which iface has the default route" do - expect(@plugin[:network][:default_interface]).to eq('e1000g0') + expect(@plugin[:network][:default_interface]).to eq("e1000g0") end end end - diff --git a/spec/unit/plugins/solaris2/platform_spec.rb b/spec/unit/plugins/solaris2/platform_spec.rb index d0193d28..1c813f72 100644 --- a/spec/unit/plugins/solaris2/platform_spec.rb +++ b/spec/unit/plugins/solaris2/platform_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris plugin platform" do before(:each) do diff --git a/spec/unit/plugins/solaris2/virtualization_spec.rb b/spec/unit/plugins/solaris2/virtualization_spec.rb index 6c5c38fa..6e1b95e9 100644 --- a/spec/unit/plugins/solaris2/virtualization_spec.rb +++ b/spec/unit/plugins/solaris2/virtualization_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris virtualization platform" do before(:each) do @@ -72,7 +72,7 @@ PSRINFO_PV end it "should set virtualpc guest if smbios detects Microsoft Virtual Machine" do - ms_vpc_smbios=<<-MSVPC + ms_vpc_smbios = <<-MSVPC ID SIZE TYPE 1 72 SMB_TYPE_SYSTEM (system information) @@ -91,7 +91,7 @@ MSVPC end it "should set vmware guest if smbios detects VMware Virtual Platform" do - vmware_smbios=<<-VMWARE + vmware_smbios = <<-VMWARE ID SIZE TYPE 1 72 SMB_TYPE_SYSTEM (system information) @@ -121,5 +121,3 @@ VMWARE expect(@plugin[:virtualization]).to eq({}) end end - - diff --git a/spec/unit/plugins/solaris2/zpools_spec.rb b/spec/unit/plugins/solaris2/zpools_spec.rb index 9ddb48b7..b53b659b 100644 --- a/spec/unit/plugins/solaris2/zpools_spec.rb +++ b/spec/unit/plugins/solaris2/zpools_spec.rb @@ -13,7 +13,7 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Solaris 2.x zpool plugin" do before(:each) do @@ -62,9 +62,9 @@ EOST rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34 tank 130T 4.91M 130T 0% 1.00x ONLINE 34 EOZO - allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,"")) - allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0,@zpool_status_rpool,"")) - allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0,@zpool_status_tank,"")) + allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, @zpool_out, "")) + allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status rpool\"").and_return(mock_shell_out(0, @zpool_status_rpool, "")) + allow(@plugin).to receive(:shell_out).with("su adm -c \"zpool status tank\"").and_return(mock_shell_out(0, @zpool_status_tank, "")) end describe "On Solaris2 Common" do @@ -123,7 +123,7 @@ EOZO rpool 109G 66.2G 42.8G 60% 1.00x ONLINE - tank 130T 4.91M 130T 0% 1.00x ONLINE - EOZO - allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,"")) + allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, @zpool_out, "")) end it "Won't have a version number" do @@ -140,7 +140,7 @@ EOZO rpool 109G 66.2G 42.8G 60% 1.00x ONLINE 34 tank 130T 4.91M 130T 0% 1.00x ONLINE 34 EOZO - allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0,@zpool_out,"")) + allow(@plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, @zpool_out, "")) end it "Should have a version number" do diff --git a/spec/unit/plugins/ssh_host_keys_spec.rb b/spec/unit/plugins/ssh_host_keys_spec.rb index 8c765076..7bdf90d8 100644 --- a/spec/unit/plugins/ssh_host_keys_spec.rb +++ b/spec/unit/plugins/ssh_host_keys_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) describe Ohai::System, "ssh_host_key plugin" do diff --git a/spec/unit/plugins/virtualbox_spec.rb b/spec/unit/plugins/virtualbox_spec.rb index 95a345cf..49e2268f 100644 --- a/spec/unit/plugins/virtualbox_spec.rb +++ b/spec/unit/plugins/virtualbox_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) +require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "/spec_helper.rb")) vbox_output = < 'Intel64 Family 6 Model 70 Stepping 1', - 'deviceid' => 'CPU0', - 'family' => 2, - 'l2cachesize' => 0, - 'manufacturer' => 'GenuineIntel', - 'maxclockspeed' => 2793, - 'numberofcores' => 1, - 'numberoflogicalprocessors' => 2, - 'revision' => 17_921, - 'stepping' => 9, - 'l2cachesize' => 64 }, - - { 'description' => 'Intel64 Family 6 Model 70 Stepping 1', - 'deviceid' => 'CPU1', - 'family' => 2, - 'l2cachesize' => 0, - 'manufacturer' => 'GenuineIntel', - 'maxclockspeed' => 2793, - 'numberofcores' => 1, - 'numberoflogicalprocessors' => 2, - 'revision' => 17_921, - 'stepping' => 9, - 'l2cachesize' => 64 }] + @processors = [{ "description" => "Intel64 Family 6 Model 70 Stepping 1", + "deviceid" => "CPU0", + "family" => 2, + "l2cachesize" => 0, + "manufacturer" => "GenuineIntel", + "maxclockspeed" => 2793, + "numberofcores" => 1, + "numberoflogicalprocessors" => 2, + "revision" => 17_921, + "stepping" => 9, + "l2cachesize" => 64 }, + + { "description" => "Intel64 Family 6 Model 70 Stepping 1", + "deviceid" => "CPU1", + "family" => 2, + "l2cachesize" => 0, + "manufacturer" => "GenuineIntel", + "maxclockspeed" => 2793, + "numberofcores" => 1, + "numberoflogicalprocessors" => 2, + "revision" => 17_921, + "stepping" => 9, + "l2cachesize" => 64 }] allow(WmiLite::Wmi).to receive(:new).and_return(@double_wmi_instance) allow(@double_wmi_instance).to receive(:instances_of) - .with('Win32_Processor') + .with("Win32_Processor") .and_return(@processors) @plugin.run end - it 'should set total cpu to 2' do + it "should set total cpu to 2" do expect(@plugin[:cpu][:total]).to eq(4) end - it 'should set real cpu to 2' do + it "should set real cpu to 2" do expect(@plugin[:cpu][:real]).to eq(2) end - it 'should set 2 distinct cpus numbered 0 and 1' do - expect(@plugin[:cpu]).to have_key('0') - expect(@plugin[:cpu]).to have_key('1') + it "should set 2 distinct cpus numbered 0 and 1" do + expect(@plugin[:cpu]).to have_key("0") + expect(@plugin[:cpu]).to have_key("1") end - it_behaves_like 'a cpu', 0 - it_behaves_like 'a cpu', 1 + it_behaves_like "a cpu", 0 + it_behaves_like "a cpu", 1 end diff --git a/spec/unit/plugins/windows/memory_spec.rb b/spec/unit/plugins/windows/memory_spec.rb index db9de630..0579439b 100644 --- a/spec/unit/plugins/windows/memory_spec.rb +++ b/spec/unit/plugins/windows/memory_spec.rb @@ -14,19 +14,19 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") describe Ohai::System, "Windows memory plugin", :windows_only do before do require "wmi-lite/wmi" @plugin = get_plugin("windows/memory") - mock_os = { + mock_os = { "TotalVisibleMemorySize" => "10485760", "FreePhysicalMemory" => "5242880", "SizeStoredInPagingFiles" => "20971520", - "FreeSpaceInPagingFiles" => "15728640" + "FreeSpaceInPagingFiles" => "15728640", } - expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with('Win32_OperatingSystem').and_return(mock_os) + expect_any_instance_of(WmiLite::Wmi).to receive(:first_of).with("Win32_OperatingSystem").and_return(mock_os) end it "should get total memory" do @@ -49,4 +49,4 @@ describe Ohai::System, "Windows memory plugin", :windows_only do expect(@plugin["memory"]["swap"]["free"]).to eql("15728640kB") end -end \ No newline at end of file +end diff --git a/spec/unit/plugins/windows/virtualization_spec.rb b/spec/unit/plugins/windows/virtualization_spec.rb index 584a1519..124e92f6 100644 --- a/spec/unit/plugins/windows/virtualization_spec.rb +++ b/spec/unit/plugins/windows/virtualization_spec.rb @@ -18,197 +18,197 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb") -describe Ohai::System, 'Windows virtualization platform' do - let(:plugin) { get_plugin('windows/virtualization') } +describe Ohai::System, "Windows virtualization platform" do + let(:plugin) { get_plugin("windows/virtualization") } before(:each) do allow(plugin).to receive(:collect_os).and_return(:windows) end - context 'when running on vmware' do - it 'system is vmware' do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 8, 9, 10, 11, 12, 14, 15, 16, 19, 26, 27, 28, 29, 30, 32, 39, 40, 41, 42, 50, 57, 58], - 'biosversion' => ['INTEL - 6040000', 'PhoenixBIOS 4.0 Release 6.0 '], - 'buildnumber' => nil, - 'caption' => 'PhoenixBIOS 4.0 Release 6.0 ', - 'codeset' => nil, 'currentlanguage' => nil, - 'description' => 'PhoenixBIOS 4.0 Release 6.0 ', - 'identificationcode' => nil, - 'installablelanguages' => nil, - 'installdate' => nil, - 'languageedition' => nil, - 'listoflanguages' => nil, - 'manufacturer' => 'Phoenix Technologies LTD', - 'name' => 'PhoenixBIOS 4.0 Release 6.0 ', - 'othertargetos' => nil, - 'primarybios' => true, - 'releasedate' => '20130731000000.000000+000', - 'serialnumber' => 'VMware-56 4d 65 24 ac cf ec 72-fa 29 b2 7d 8f df b2 7a', - 'smbiosbiosversion' => '6.00', - 'smbiosmajorversion' => 2, - 'smbiosminorversion' => 4, - 'smbiospresent' => true, - 'softwareelementid' => 'PhoenixBIOS 4.0 Release 6.0 ', - 'softwareelementstate' => 3, - 'status' => 'OK', - 'targetoperatingsystem' => 0, - 'version' => 'INTEL - 6040000' + context "when running on vmware" do + it "system is vmware" do + allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [4, 7, 8, 9, 10, 11, 12, 14, 15, 16, 19, 26, 27, 28, 29, 30, 32, 39, 40, 41, 42, 50, 57, 58], + "biosversion" => ["INTEL - 6040000", "PhoenixBIOS 4.0 Release 6.0 "], + "buildnumber" => nil, + "caption" => "PhoenixBIOS 4.0 Release 6.0 ", + "codeset" => nil, "currentlanguage" => nil, + "description" => "PhoenixBIOS 4.0 Release 6.0 ", + "identificationcode" => nil, + "installablelanguages" => nil, + "installdate" => nil, + "languageedition" => nil, + "listoflanguages" => nil, + "manufacturer" => "Phoenix Technologies LTD", + "name" => "PhoenixBIOS 4.0 Release 6.0 ", + "othertargetos" => nil, + "primarybios" => true, + "releasedate" => "20130731000000.000000+000", + "serialnumber" => "VMware-56 4d 65 24 ac cf ec 72-fa 29 b2 7d 8f df b2 7a", + "smbiosbiosversion" => "6.00", + "smbiosmajorversion" => 2, + "smbiosminorversion" => 4, + "smbiospresent" => true, + "softwareelementid" => "PhoenixBIOS 4.0 Release 6.0 ", + "softwareelementstate" => 3, + "status" => "OK", + "targetoperatingsystem" => 0, + "version" => "INTEL - 6040000" }]) plugin.run - expect(plugin[:virtualization][:system]).to eq('vmware') - expect(plugin[:virtualization][:role]).to eq('guest') - expect(plugin[:virtualization][:systems][:vmware]).to eq('guest') + expect(plugin[:virtualization][:system]).to eq("vmware") + expect(plugin[:virtualization][:role]).to eq("guest") + expect(plugin[:virtualization][:systems][:vmware]).to eq("guest") end end - context 'when running on parallels desktop' do - it 'system is parallels' do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 9, 10, 15, 24, 25, 27, 28, 29, 30, 32, 42, 44, 48, 49, 51, 64, 65, 67], - 'biosversion' => ['PRLS - 1'], - 'buildnumber' => nil, - 'caption' => 'Default System BIOS', - 'codeset' => nil, - 'currentlanguage' => nil, - 'description' => 'Default System BIOS', - 'identificationcode' => nil, - 'installablelanguages' => nil, - 'installdate' => nil, - 'languageedition' => nil, - 'listoflanguages' => nil, - 'manufacturer' => 'Parallels Software International Inc.', - 'name' => 'Default System BIOS', - 'othertargetos' => nil, - 'primarybios' => true, - 'releasedate' => '20151005000000.000000+000', - 'serialnumber' => 'Parallels-82 75 A0 A0 9B B4 47 7C 87 A9 D9 E1 2B 90 4B 1F', - 'smbiosbiosversion' => '11.0.2 (31348)', - 'smbiosmajorversion' => 2, - 'smbiosminorversion' => 7, - 'smbiospresent' => true, - 'softwareelementid' => 'Default System BIOS', - 'softwareelementstate' => 3, - 'status' => 'OK', - 'targetoperatingsystem' => 0, - 'version' => 'PRLS - 1' + context "when running on parallels desktop" do + it "system is parallels" do + allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [4, 7, 9, 10, 15, 24, 25, 27, 28, 29, 30, 32, 42, 44, 48, 49, 51, 64, 65, 67], + "biosversion" => ["PRLS - 1"], + "buildnumber" => nil, + "caption" => "Default System BIOS", + "codeset" => nil, + "currentlanguage" => nil, + "description" => "Default System BIOS", + "identificationcode" => nil, + "installablelanguages" => nil, + "installdate" => nil, + "languageedition" => nil, + "listoflanguages" => nil, + "manufacturer" => "Parallels Software International Inc.", + "name" => "Default System BIOS", + "othertargetos" => nil, + "primarybios" => true, + "releasedate" => "20151005000000.000000+000", + "serialnumber" => "Parallels-82 75 A0 A0 9B B4 47 7C 87 A9 D9 E1 2B 90 4B 1F", + "smbiosbiosversion" => "11.0.2 (31348)", + "smbiosmajorversion" => 2, + "smbiosminorversion" => 7, + "smbiospresent" => true, + "softwareelementid" => "Default System BIOS", + "softwareelementstate" => 3, + "status" => "OK", + "targetoperatingsystem" => 0, + "version" => "PRLS - 1", }]) plugin.run - expect(plugin[:virtualization][:system]).to eq('parallels') - expect(plugin[:virtualization][:role]).to eq('guest') - expect(plugin[:virtualization][:systems][:parallels]).to eq('guest') + expect(plugin[:virtualization][:system]).to eq("parallels") + expect(plugin[:virtualization][:role]).to eq("guest") + expect(plugin[:virtualization][:systems][:parallels]).to eq("guest") end end - context 'when running on kvm' do - it 'system is kvm' do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [3, 42, 48, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], - 'biosversion' => ['BOCHS - 1'], - 'buildnumber' => nil, - 'caption' => 'Default System BIOS', - 'codeset' => nil, - 'currentlanguage' => nil, - 'description' => 'Default System BIOS', - 'identificationcode' => nil, - 'installablelanguages' => nil, - 'installdate' => nil, - 'languageedition' => nil, - 'listoflanguages' => nil, - 'manufacturer' => 'Bochs', - 'name' => 'Default System BIOS', - 'othertargetos' => nil, - 'primarybios' => true, - 'releasedate' => '20110101******.******+***', - 'serialnumber' => nil, - 'smbiosbiosversion' => 'Bochs', - 'smbiosmajorversion' => 2, - 'smbiosminorversion' => 4, - 'smbiospresent' => true, - 'softwareelementid' => 'Default System BIOS', - 'softwareelementstate' => 3, - 'status' => 'OK', - 'targetoperatingsystem' => 0, 'version' => 'BOCHS -1' + context "when running on kvm" do + it "system is kvm" do + allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [3, 42, 48, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], + "biosversion" => ["BOCHS - 1"], + "buildnumber" => nil, + "caption" => "Default System BIOS", + "codeset" => nil, + "currentlanguage" => nil, + "description" => "Default System BIOS", + "identificationcode" => nil, + "installablelanguages" => nil, + "installdate" => nil, + "languageedition" => nil, + "listoflanguages" => nil, + "manufacturer" => "Bochs", + "name" => "Default System BIOS", + "othertargetos" => nil, + "primarybios" => true, + "releasedate" => "20110101******.******+***", + "serialnumber" => nil, + "smbiosbiosversion" => "Bochs", + "smbiosmajorversion" => 2, + "smbiosminorversion" => 4, + "smbiospresent" => true, + "softwareelementid" => "Default System BIOS", + "softwareelementstate" => 3, + "status" => "OK", + "targetoperatingsystem" => 0, "version" => "BOCHS -1" }]) plugin.run - expect(plugin[:virtualization][:system]).to eq('kvm') - expect(plugin[:virtualization][:role]).to eq('guest') - expect(plugin[:virtualization][:systems][:kvm]).to eq('guest') + expect(plugin[:virtualization][:system]).to eq("kvm") + expect(plugin[:virtualization][:role]).to eq("guest") + expect(plugin[:virtualization][:systems][:kvm]).to eq("guest") end end - context 'when running on virtualbox' do - it 'system is vbox' do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [4, 7, 15, 16, 27, 30, 32], - 'biosversion' => ['VBOX - 1'], - 'buildnumber' => nil, - 'caption' => 'Default System BIOS', - 'codeset' => nil, - 'currentlanguage' => nil, - 'description' => 'Default System BIOS', - 'identificationcode' => nil, - 'installablelanguages' => nil, - 'installdate' => nil, - 'languageedition' => nil, - 'listoflanguages' => nil, - 'manufacturer' => 'innotek GmbH', - 'name' => 'Default System BIOS', - 'othertargetos' => nil, - 'primarybios' => true, - 'releasedate' => '20061201000000.000000+000', - 'serialnumber' => '0', - 'smbiosbiosversion' => 'VirtualBox', - 'smbiosmajorversion' => 2, - 'smbiosminorversion' => 5, - 'smbiospresent' => true, - 'softwareelementid' => 'Default System BIOS', - 'softwareelementstate' => 3, - 'status' => 'OK', - 'targetoperatingsystem' => 0, - 'version' => 'VBOX - 1' + context "when running on virtualbox" do + it "system is vbox" do + allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [4, 7, 15, 16, 27, 30, 32], + "biosversion" => ["VBOX - 1"], + "buildnumber" => nil, + "caption" => "Default System BIOS", + "codeset" => nil, + "currentlanguage" => nil, + "description" => "Default System BIOS", + "identificationcode" => nil, + "installablelanguages" => nil, + "installdate" => nil, + "languageedition" => nil, + "listoflanguages" => nil, + "manufacturer" => "innotek GmbH", + "name" => "Default System BIOS", + "othertargetos" => nil, + "primarybios" => true, + "releasedate" => "20061201000000.000000+000", + "serialnumber" => "0", + "smbiosbiosversion" => "VirtualBox", + "smbiosmajorversion" => 2, + "smbiosminorversion" => 5, + "smbiospresent" => true, + "softwareelementid" => "Default System BIOS", + "softwareelementstate" => 3, + "status" => "OK", + "targetoperatingsystem" => 0, + "version" => "VBOX - 1", }]) plugin.run - expect(plugin[:virtualization][:system]).to eq('vbox') - expect(plugin[:virtualization][:role]).to eq('guest') - expect(plugin[:virtualization][:systems][:vbox]).to eq('guest') + expect(plugin[:virtualization][:system]).to eq("vbox") + expect(plugin[:virtualization][:role]).to eq("guest") + expect(plugin[:virtualization][:systems][:vbox]).to eq("guest") end end - context 'when running on a hardware system' do - it 'does not set virtualization attributes' do - allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with('Win32_BIOS').and_return([{ 'bioscharacteristics' => [7, 11, 12, 15, 16, 17, 19, 23, 24, 25, 26, 27, 28, 29, 32, 33, 40, 42, 43], - 'biosversion' => ['DELL - 1072009', 'A10', 'American Megatrends - 4028D'], - 'buildnumber' => nil, - 'caption' => 'A10', - 'codeset' => nil, - 'currentlanguage' => nil, - 'description' => 'A10', - 'embeddedcontrollermajorversion' => 255, - 'embeddedcontrollerminorversion' => 255, - 'identificationcode' => nil, - 'installablelanguages' => nil, - 'installdate' => nil, - 'languageedition' => nil, - 'listoflanguages' => nil, - 'manufacturer' => 'Dell Inc.', - 'name' => 'A10', - 'othertargetos' => nil, - 'primarybios' => true, - 'releasedate' => '20130513000000.000000+000', - 'serialnumber' => '87GBNY1', - 'smbiosbiosversion' => 'A10', - 'smbiosmajorversion' => 2, - 'smbiosminorversion' => 7, - 'smbiospresent' => true, - 'softwareelementid' => 'A10', - 'softwareelementstate' => 3, - 'status' => 'OK', - 'systembiosmajorversion' => 4, - 'systembiosminorversion' => 6, - 'targetoperatingsystem' => 0, - 'version' => 'DELL - 1072009' + context "when running on a hardware system" do + it "does not set virtualization attributes" do + allow_any_instance_of(WmiLite::Wmi).to receive(:instances_of).with("Win32_BIOS").and_return([{ "bioscharacteristics" => [7, 11, 12, 15, 16, 17, 19, 23, 24, 25, 26, 27, 28, 29, 32, 33, 40, 42, 43], + "biosversion" => ["DELL - 1072009", "A10", "American Megatrends - 4028D"], + "buildnumber" => nil, + "caption" => "A10", + "codeset" => nil, + "currentlanguage" => nil, + "description" => "A10", + "embeddedcontrollermajorversion" => 255, + "embeddedcontrollerminorversion" => 255, + "identificationcode" => nil, + "installablelanguages" => nil, + "installdate" => nil, + "languageedition" => nil, + "listoflanguages" => nil, + "manufacturer" => "Dell Inc.", + "name" => "A10", + "othertargetos" => nil, + "primarybios" => true, + "releasedate" => "20130513000000.000000+000", + "serialnumber" => "87GBNY1", + "smbiosbiosversion" => "A10", + "smbiosmajorversion" => 2, + "smbiosminorversion" => 7, + "smbiospresent" => true, + "softwareelementid" => "A10", + "softwareelementstate" => 3, + "status" => "OK", + "systembiosmajorversion" => 4, + "systembiosminorversion" => 6, + "targetoperatingsystem" => 0, + "version" => "DELL - 1072009", }]) plugin.run - expect(plugin[:virtualization]).to eq('systems' => {}) + expect(plugin[:virtualization]).to eq("systems" => {}) end end end diff --git a/spec/unit/provides_map_spec.rb b/spec/unit/provides_map_spec.rb index fb444056..5a6eb1fe 100644 --- a/spec/unit/provides_map_spec.rb +++ b/spec/unit/provides_map_spec.rb @@ -17,7 +17,7 @@ # limitations under the License # -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::ProvidesMap do @@ -31,14 +31,14 @@ describe Ohai::ProvidesMap do describe "when looking up providing plugins for a single attribute" do describe "when the attribute does not exist" do it "should raise Ohai::Exceptions::AttributeNotFound error" do - expect{ provides_map.find_providers_for(["single"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'single'") + expect { provides_map.find_providers_for(["single"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'single'") end end describe "when the attribute does not have a provider" do it "should raise Ohai::Exceptions::ProviderNotFound error" do provides_map.set_providers_for(plugin_1, ["first/second"]) - expect{ provides_map.find_providers_for(["first"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'first'") + expect { provides_map.find_providers_for(["first"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'first'") end end @@ -73,7 +73,7 @@ describe Ohai::ProvidesMap do end it "should return each provider" do - expect(provides_map.find_providers_for(["one", "two"])).to eq([plugin_1, plugin_2]) + expect(provides_map.find_providers_for(%w{one two})).to eq([plugin_1, plugin_2]) end end @@ -85,7 +85,7 @@ describe Ohai::ProvidesMap do end it "should return unique providers" do - expect(provides_map.find_providers_for(["one", "one_again"])).to eq([plugin_1]) + expect(provides_map.find_providers_for(%w{one one_again})).to eq([plugin_1]) end end end @@ -105,13 +105,13 @@ describe Ohai::ProvidesMap do describe "when setting multi-level attributes" do describe "when the attribute contains //" do it "should raise an Ohai::Exceptions::AttributeSyntaxError" do - expect{ provides_map.set_providers_for(plugin_1, ["this/plugin//is/bad"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: this/plugin//is/bad") + expect { provides_map.set_providers_for(plugin_1, ["this/plugin//is/bad"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains duplicate '/' characters: this/plugin//is/bad") end end describe "when the attribute has a trailing slash" do it "should raise an Ohai::Exceptions::AttributeSyntaxError" do - expect{ provides_map.set_providers_for(plugin_1, ["this/plugin/is/bad/"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': this/plugin/is/bad/") + expect { provides_map.set_providers_for(plugin_1, ["this/plugin/is/bad/"]) }.to raise_error(Ohai::Exceptions::AttributeSyntaxError, "Attribute contains a trailing '/': this/plugin/is/bad/") end end end @@ -154,7 +154,7 @@ describe Ohai::ProvidesMap do end it "should not raise error if a parent attribute is provided" do - expect{ provides_map.find_closest_providers_for(["do/not/eat/plastic"]) }.not_to raise_error + expect { provides_map.find_closest_providers_for(["do/not/eat/plastic"]) }.not_to raise_error end it "should return the providers of the closest parent attribute" do @@ -163,11 +163,11 @@ describe Ohai::ProvidesMap do end it "should raise error if the least-specific parent is not an attribute" do - expect{ provides_map.find_closest_providers_for(["please/eat/your/vegetables"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'please/eat/your/vegetables'") + expect { provides_map.find_closest_providers_for(["please/eat/your/vegetables"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'please/eat/your/vegetables'") end it "should raise error if no parent attribute has a provider" do - expect{ provides_map.find_closest_providers_for(["do/not"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'do/not'") + expect { provides_map.find_closest_providers_for(["do/not"]) }.to raise_error(Ohai::Exceptions::ProviderNotFound, "Cannot find plugin providing attribute: 'do/not'") end end end diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index d4a9523f..c35ad64d 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -17,7 +17,7 @@ # limitations under the License # -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb') +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") describe Ohai::Runner, "run_plugin" do let(:safe_run) { true } @@ -137,11 +137,11 @@ describe Ohai::Runner, "run_plugin" do end it "should raise Ohai::Excpetions::AttributeNotFound" do - expect{ @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) + expect { @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) end it "should not run the plugin" do - expect{ @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) + expect { @runner.run_plugin(@plugin) }.to raise_error(Ohai::Exceptions::AttributeNotFound) expect(@plugin.has_run?).to be false end end @@ -244,8 +244,8 @@ describe Ohai::Runner, "run_plugin" do @plugins << klass.new(@ohai.data) end @plugin1, @plugin2, @plugin3 = @plugins - @ohai.provides_map.set_providers_for(@plugin1, ["one", "two"]) - @ohai.provides_map.set_providers_for(@plugin2, ["one", "two"]) + @ohai.provides_map.set_providers_for(@plugin1, %w{one two}) + @ohai.provides_map.set_providers_for(@plugin2, %w{one two}) end it "should run the plugins" do @@ -322,16 +322,16 @@ describe Ohai::Runner, "run_plugin" do klassA = Ohai.plugin(:A) { provides("A") depends("B", "C") - collect_data { } + collect_data {} } klassB = Ohai.plugin(:B) { provides("B") depends("C") - collect_data { } + collect_data {} } klassC = Ohai.plugin(:C) { provides("C") - collect_data { } + collect_data {} } @plugins = [] @@ -373,7 +373,7 @@ describe Ohai::Runner, "fetch_plugins" do before(:each) do @provides_map = Ohai::ProvidesMap.new @data = Mash.new - @ohai = double('Ohai::System', :data => @data, :provides_map => @provides_map) + @ohai = double("Ohai::System", :data => @data, :provides_map => @provides_map) @runner = Ohai::Runner.new(@ohai, true) end @@ -397,7 +397,7 @@ describe Ohai::Runner, "fetch_plugins" do describe "and no parent attribute has providers" do it "should raise Ohai::Exceptions::AttributeNotFound exception" do # provides map is empty - expect{ @runner.fetch_plugins(["false/attribute"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'false/attribute'") + expect { @runner.fetch_plugins(["false/attribute"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound, "No such attribute: 'false/attribute'") end end end diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb index 91e5e47f..8b2754ca 100644 --- a/spec/unit/system_spec.rb +++ b/spec/unit/system_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb') -require 'ohai/mixin/os' +require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb") +require "ohai/mixin/os" describe "Ohai::System" do extend IntegrationSupport @@ -38,7 +38,7 @@ describe "Ohai::System" do expect(ohai.v6_dependency_solver).to be_a_kind_of(Hash) end - it 'merges deprecated config settings into the ohai config context' do + it "merges deprecated config settings into the ohai config context" do expect(Ohai::Log).to receive(:warn). with(/Ohai::Config\[:disabled_plugins\] is deprecated/) Ohai::Config[:disabled_plugins] = [ :Foo, :Baz ] @@ -48,10 +48,10 @@ describe "Ohai::System" do expect(Ohai.config[:disabled_plugins]).to eq([ :Foo, :Baz ]) end - it 'merges provided configuration options into the ohai config context' do + it "merges provided configuration options into the ohai config context" do config = { disabled_plugins: [ :Foo, :Baz ], - directory: '/some/extra/plugins' + directory: "/some/extra/plugins", } allow(Ohai::Config).to receive(:merge_deprecated_config) expect(Ohai.config).to receive(:merge!).with(config).and_call_original @@ -61,18 +61,18 @@ describe "Ohai::System" do end end - context 'when directory is configured' do - let(:directory) { '/some/fantastic/plugins' } + context "when directory is configured" do + let(:directory) { "/some/fantastic/plugins" } - it 'adds directory to plugin_path' do + it "adds directory to plugin_path" do Ohai.config[:directory] = directory Ohai::System.new expect(Ohai.config[:plugin_path]).to include(directory) end end - shared_examples_for 'appendable deprecated configuration option' do - it 'logs a warning and configures the option on the ohai config context' do + shared_examples_for "appendable deprecated configuration option" do + it "logs a warning and configures the option on the ohai config context" do Ohai::Config[option] << value expect(Ohai::Log).to receive(:warn). with(/Ohai::Config\[:#{option}\] is deprecated/) @@ -81,21 +81,21 @@ describe "Ohai::System" do end end - context 'when a top-level hints_path is configured' do - include_examples 'appendable deprecated configuration option' do + context "when a top-level hints_path is configured" do + include_examples "appendable deprecated configuration option" do let(:option) { :hints_path } - let(:value) { '/path/to/hints' } + let(:value) { "/path/to/hints" } end end - context 'when a top-level plugin_path is configured' do - include_examples 'appendable deprecated configuration option' do + context "when a top-level plugin_path is configured" do + include_examples "appendable deprecated configuration option" do let(:option) { :plugin_path } - let(:value) { '/path/to/plugins' } + let(:value) { "/path/to/plugins" } end end - it 'configures logging' do + it "configures logging" do log_level = :debug Ohai.config[:log_level] = log_level expect(Ohai::Log).to receive(:init).with(Ohai.config[:log_location]) @@ -103,7 +103,7 @@ describe "Ohai::System" do Ohai::System.new end - it 'resolves log_level when set to :auto' do + it "resolves log_level when set to :auto" do expect(Ohai::Log).to receive(:level=).with(:info) Ohai::System.new end @@ -394,7 +394,7 @@ EOF describe "when using :disabled_plugins" do before do - Ohai.config[:disabled_plugins] = [ :Zoo, 'my_plugins::park' ] + Ohai.config[:disabled_plugins] = [ :Zoo, "my_plugins::park" ] end after do diff --git a/spec/unit/util/file_helper_spec.rb b/spec/unit/util/file_helper_spec.rb index 3acec6ea..be68a321 100644 --- a/spec/unit/util/file_helper_spec.rb +++ b/spec/unit/util/file_helper_spec.rb @@ -16,14 +16,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'ohai/util/file_helper' +require "spec_helper" +require "ohai/util/file_helper" class FileHelperMock include Ohai::Util::FileHelper end - describe "Ohai::Util::FileHelper" do let(:file_helper) { FileHelperMock.new } @@ -33,13 +32,13 @@ describe "Ohai::Util::FileHelper" do describe "which" do it "returns the path to an executable that is in the path" do - allow(File).to receive(:executable?).with('/usr/bin/skyhawk').and_return(true) + allow(File).to receive(:executable?).with("/usr/bin/skyhawk").and_return(true) - expect(file_helper.which('skyhawk')).to eql "/usr/bin/skyhawk" + expect(file_helper.which("skyhawk")).to eql "/usr/bin/skyhawk" end it "returns false if the executable is not in the path" do - expect(file_helper.which('the_cake')).to be false + expect(file_helper.which("the_cake")).to be false end end end diff --git a/spec/unit/util/ip_helper_spec.rb b/spec/unit/util/ip_helper_spec.rb index 2eaa85f1..766a9636 100644 --- a/spec/unit/util/ip_helper_spec.rb +++ b/spec/unit/util/ip_helper_spec.rb @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'ipaddress' -require 'spec_helper' -require 'ohai/util/ip_helper' +require "ipaddress" +require "spec_helper" +require "ohai/util/ip_helper" class IpHelperMock include Ohai::Util::IpHelper @@ -25,54 +25,54 @@ end describe "Ohai::Util::IpHelper" do let(:ip_helper) { IpHelperMock.new } - shared_examples 'ip address types' do - context 'with an IPv4 address' do - context 'that is private' do - let(:address) { '10.128.142.89' } + shared_examples "ip address types" do + context "with an IPv4 address" do + context "that is private" do + let(:address) { "10.128.142.89" } - it 'identifies the address as private' do + it "identifies the address as private" do expect(ip_helper.private_address?(address)).to be_truthy end end - context 'that is public' do - let(:address) { '74.125.224.72' } + context "that is public" do + let(:address) { "74.125.224.72" } - it 'identifies the address as public' do + it "identifies the address as public" do expect(ip_helper.private_address?(address)).to be_falsey end end end - context 'with an IPv6 address' do - context 'that is an RFC 4193 unique local address' do - let(:address) { 'fdf8:f53b:82e4::53' } + context "with an IPv6 address" do + context "that is an RFC 4193 unique local address" do + let(:address) { "fdf8:f53b:82e4::53" } - it 'identifies the address as a unique local address' do + it "identifies the address as a unique local address" do expect(ip_helper.private_address?(address)).to be_truthy end end - context 'that is a RFC 4291 Link-Local unicast address' do - let(:address) { 'FE80::0202:B3FF:FE1E:8329' } + context "that is a RFC 4291 Link-Local unicast address" do + let(:address) { "FE80::0202:B3FF:FE1E:8329" } - it 'does identify the address as a link-local address' do + it "does identify the address as a link-local address" do expect(ip_helper.private_address?(address)).to be_truthy end end end end - describe 'private_address?' do - include_examples 'ip address types' + describe "private_address?" do + include_examples "ip address types" end - describe 'unique_local_address?' do - include_examples 'ip address types' + describe "unique_local_address?" do + include_examples "ip address types" end - describe 'public_address?' do - let(:address) { '10.128.142.89' } + describe "public_address?" do + let(:address) { "10.128.142.89" } before do allow(ip_helper).to receive(:private_address?) @@ -88,38 +88,38 @@ describe "Ohai::Util::IpHelper" do end end - describe 'loopback?' do - context 'with an IPv4 address' do - context 'that is a loopback address' do - let(:address) { '127.0.0.1' } + describe "loopback?" do + context "with an IPv4 address" do + context "that is a loopback address" do + let(:address) { "127.0.0.1" } - it 'should identify the address as a loopback address' do + it "should identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_truthy end end - context 'that is not a loopback address' do - let(:address) { '1.2.3.4' } + context "that is not a loopback address" do + let(:address) { "1.2.3.4" } - it 'should not identify the address as a loopback address' do + it "should not identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_falsey end end end - context 'with an IPv6 address' do - context 'that is a loopback address' do - let(:address) { '0:0:0:0:0:0:0:1' } + context "with an IPv6 address" do + context "that is a loopback address" do + let(:address) { "0:0:0:0:0:0:0:1" } - it 'should identify the address as a loopback address' do + it "should identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_truthy end end - context 'that is not a loopback address' do - let(:address) { '2400:6180:0000:00D0:0000:0000:0009:7001' } + context "that is not a loopback address" do + let(:address) { "2400:6180:0000:00D0:0000:0000:0009:7001" } - it 'should not identify the address as a loopback address' do + it "should not identify the address as a loopback address" do expect(ip_helper.loopback?(address)).to be_falsey end end -- cgit v1.2.1