summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ohai.rb8
-rw-r--r--lib/ohai/application.rb13
-rw-r--r--lib/ohai/common/dmi.rb112
-rw-r--r--lib/ohai/config.rb20
-rw-r--r--lib/ohai/dsl.rb6
-rw-r--r--lib/ohai/dsl/plugin.rb10
-rw-r--r--lib/ohai/dsl/plugin/versionvi.rb1
-rw-r--r--lib/ohai/dsl/plugin/versionvii.rb1
-rw-r--r--lib/ohai/hints.rb2
-rw-r--r--lib/ohai/loader.rb12
-rw-r--r--lib/ohai/log.rb2
-rw-r--r--lib/ohai/mash.rb5
-rw-r--r--lib/ohai/mixin/command.rb63
-rw-r--r--lib/ohai/mixin/dmi_decode.rb16
-rw-r--r--lib/ohai/mixin/ec2_metadata.rb62
-rw-r--r--lib/ohai/mixin/gce_metadata.rb18
-rw-r--r--lib/ohai/mixin/network_constants.rb2
-rw-r--r--lib/ohai/mixin/os.rb6
-rw-r--r--lib/ohai/mixin/seconds_to_human.rb2
-rw-r--r--lib/ohai/mixin/softlayer_metadata.rb20
-rw-r--r--lib/ohai/mixin/string.rb4
-rw-r--r--lib/ohai/plugin_config.rb2
-rw-r--r--lib/ohai/plugins/aix/cpu.rb4
-rw-r--r--lib/ohai/plugins/aix/filesystem.rb4
-rw-r--r--lib/ohai/plugins/aix/memory.rb4
-rw-r--r--lib/ohai/plugins/aix/network.rb19
-rw-r--r--lib/ohai/plugins/aix/os.rb4
-rw-r--r--lib/ohai/plugins/aix/uptime.rb6
-rw-r--r--lib/ohai/plugins/aix/virtualization.rb46
-rw-r--r--lib/ohai/plugins/azure.rb8
-rw-r--r--lib/ohai/plugins/bsd/virtualization.rb44
-rw-r--r--lib/ohai/plugins/c.rb6
-rw-r--r--lib/ohai/plugins/chef.rb2
-rw-r--r--lib/ohai/plugins/cloud.rb119
-rw-r--r--lib/ohai/plugins/cloud_v2.rb76
-rw-r--r--lib/ohai/plugins/darwin/cpu.rb2
-rw-r--r--lib/ohai/plugins/darwin/filesystem2.rb10
-rw-r--r--lib/ohai/plugins/darwin/memory.rb11
-rw-r--r--lib/ohai/plugins/darwin/network.rb16
-rw-r--r--lib/ohai/plugins/darwin/system_profiler.rb65
-rw-r--r--lib/ohai/plugins/darwin/virtualization.rb18
-rw-r--r--lib/ohai/plugins/digital_ocean.rb26
-rw-r--r--lib/ohai/plugins/dmi.rb12
-rw-r--r--lib/ohai/plugins/dragonflybsd/cpu.rb4
-rw-r--r--lib/ohai/plugins/dragonflybsd/memory.rb1
-rw-r--r--lib/ohai/plugins/dragonflybsd/network.rb8
-rw-r--r--lib/ohai/plugins/dragonflybsd/os.rb2
-rw-r--r--lib/ohai/plugins/ec2.rb12
-rw-r--r--lib/ohai/plugins/elixir.rb2
-rw-r--r--lib/ohai/plugins/erlang.rb6
-rw-r--r--lib/ohai/plugins/eucalyptus.rb8
-rw-r--r--lib/ohai/plugins/freebsd/cpu.rb4
-rw-r--r--lib/ohai/plugins/freebsd/memory.rb1
-rw-r--r--lib/ohai/plugins/freebsd/network.rb8
-rw-r--r--lib/ohai/plugins/freebsd/os.rb2
-rw-r--r--lib/ohai/plugins/gce.rb8
-rw-r--r--lib/ohai/plugins/hostname.rb14
-rw-r--r--lib/ohai/plugins/init_package.rb2
-rw-r--r--lib/ohai/plugins/ip_scopes.rb18
-rw-r--r--lib/ohai/plugins/joyent.rb14
-rw-r--r--lib/ohai/plugins/kernel.rb16
-rw-r--r--lib/ohai/plugins/linode.rb8
-rw-r--r--lib/ohai/plugins/linux/cpu.rb8
-rw-r--r--lib/ohai/plugins/linux/filesystem.rb32
-rw-r--r--lib/ohai/plugins/linux/filesystem2.rb30
-rw-r--r--lib/ohai/plugins/linux/mdadm.rb6
-rw-r--r--lib/ohai/plugins/linux/network.rb46
-rw-r--r--lib/ohai/plugins/linux/platform.rb48
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb14
-rw-r--r--lib/ohai/plugins/mono.rb2
-rw-r--r--lib/ohai/plugins/netbsd/cpu.rb2
-rw-r--r--lib/ohai/plugins/netbsd/network.rb4
-rw-r--r--lib/ohai/plugins/network.rb28
-rw-r--r--lib/ohai/plugins/network_listeners.rb4
-rw-r--r--lib/ohai/plugins/ohai.rb6
-rw-r--r--lib/ohai/plugins/openbsd/cpu.rb8
-rw-r--r--lib/ohai/plugins/openbsd/memory.rb8
-rw-r--r--lib/ohai/plugins/openbsd/network.rb6
-rw-r--r--lib/ohai/plugins/openstack.rb24
-rw-r--r--lib/ohai/plugins/os.rb4
-rw-r--r--lib/ohai/plugins/packages.rb44
-rw-r--r--lib/ohai/plugins/passwd.rb8
-rw-r--r--lib/ohai/plugins/powershell.rb18
-rw-r--r--lib/ohai/plugins/ps.rb4
-rw-r--r--lib/ohai/plugins/python.rb2
-rw-r--r--lib/ohai/plugins/rackspace.rb22
-rw-r--r--lib/ohai/plugins/root_group.rb8
-rw-r--r--lib/ohai/plugins/ruby.rb12
-rw-r--r--lib/ohai/plugins/rust.rb2
-rw-r--r--lib/ohai/plugins/sigar/cpu.rb2
-rw-r--r--lib/ohai/plugins/sigar/filesystem.rb2
-rw-r--r--lib/ohai/plugins/sigar/network.rb26
-rw-r--r--lib/ohai/plugins/sigar/network_route.rb8
-rw-r--r--lib/ohai/plugins/softlayer.rb8
-rw-r--r--lib/ohai/plugins/solaris2/cpu.rb38
-rw-r--r--lib/ohai/plugins/solaris2/dmi.rb124
-rw-r--r--lib/ohai/plugins/solaris2/filesystem.rb26
-rw-r--r--lib/ohai/plugins/solaris2/memory.rb4
-rw-r--r--lib/ohai/plugins/solaris2/network.rb10
-rw-r--r--lib/ohai/plugins/solaris2/virtualization.rb36
-rw-r--r--lib/ohai/plugins/ssh_host_key.rb4
-rw-r--r--lib/ohai/plugins/uptime.rb9
-rw-r--r--lib/ohai/plugins/virtualbox.rb4
-rw-r--r--lib/ohai/plugins/virtualization.rb34
-rw-r--r--lib/ohai/plugins/vmware.rb4
-rw-r--r--lib/ohai/plugins/windows/cpu.rb28
-rw-r--r--lib/ohai/plugins/windows/drivers.rb16
-rw-r--r--lib/ohai/plugins/windows/filesystem.rb8
-rw-r--r--lib/ohai/plugins/windows/memory.rb2
-rw-r--r--lib/ohai/plugins/windows/network.rb18
-rw-r--r--lib/ohai/plugins/windows/platform.rb3
-rw-r--r--lib/ohai/plugins/windows/virtualization.rb34
-rw-r--r--lib/ohai/provides_map.rb14
-rw-r--r--lib/ohai/runner.rb6
-rw-r--r--lib/ohai/system.rb43
-rw-r--r--lib/ohai/util/file_helper.rb3
-rw-r--r--lib/ohai/util/ip_helper.rb8
-rw-r--r--lib/ohai/util/win32.rb10
-rw-r--r--lib/ohai/util/win32/group_helper.rb9
-rw-r--r--lib/ohai/version.rb2
120 files changed, 981 insertions, 989 deletions
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<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<Object> 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?("<UP,") ? 'up' : 'down')
+ iface[interface][:state] = (line.include?("<UP,") ? "up" : "down")
intraface.lines.each do |lin|
case lin
when /flags=\S+<(\S+)>/
- 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<SSE3,<b31>>
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 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
+ # ed0 1500 <Link#1> 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+<Link#\d+>\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<SSE3,<b31>>
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 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
+ # ed0 1500 <Link#1> 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+<Link#\d+>\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<Symbol>:: 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 <param> commands
# Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value
# to attribute "vmware[:<parameter>]"
- [ "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 <param> status commands
# Iterate through each parameter supported by the "vwware-toolbox-cmd status" command, assign value
# to attribute "vmware[:<parameter>]"
- [ "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