ohai 15.0.35 → 15.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohai.rb +4 -4
- data/lib/ohai/application.rb +3 -3
- data/lib/ohai/config.rb +2 -2
- data/lib/ohai/dsl.rb +2 -2
- data/lib/ohai/dsl/plugin.rb +5 -5
- data/lib/ohai/hints.rb +1 -1
- data/lib/ohai/loader.rb +4 -4
- data/lib/ohai/mixin/azure_metadata.rb +3 -3
- data/lib/ohai/mixin/command.rb +3 -3
- data/lib/ohai/mixin/do_metadata.rb +3 -3
- data/lib/ohai/mixin/ec2_metadata.rb +6 -6
- data/lib/ohai/mixin/gce_metadata.rb +3 -3
- data/lib/ohai/mixin/http_helper.rb +1 -1
- data/lib/ohai/mixin/scaleway_metadata.rb +3 -3
- data/lib/ohai/mixin/softlayer_metadata.rb +2 -2
- data/lib/ohai/plugin_config.rb +1 -1
- data/lib/ohai/plugins/aix/network.rb +6 -6
- data/lib/ohai/plugins/azure.rb +2 -2
- data/lib/ohai/plugins/bsd/virtualization.rb +2 -2
- data/lib/ohai/plugins/darwin/network.rb +14 -13
- data/lib/ohai/plugins/darwin/virtualization.rb +1 -1
- data/lib/ohai/plugins/digital_ocean.rb +2 -2
- data/lib/ohai/plugins/dmi.rb +3 -3
- data/lib/ohai/plugins/dragonflybsd/network.rb +9 -9
- data/lib/ohai/plugins/ec2.rb +2 -2
- data/lib/ohai/plugins/eucalyptus.rb +2 -2
- data/lib/ohai/plugins/filesystem.rb +5 -5
- data/lib/ohai/plugins/freebsd/network.rb +9 -9
- data/lib/ohai/plugins/gce.rb +2 -2
- data/lib/ohai/plugins/hostname.rb +2 -2
- data/lib/ohai/plugins/kernel.rb +1 -1
- data/lib/ohai/plugins/linux/fips.rb +1 -1
- data/lib/ohai/plugins/linux/network.rb +18 -18
- data/lib/ohai/plugins/linux/platform.rb +1 -3
- data/lib/ohai/plugins/linux/sessions.rb +2 -2
- data/lib/ohai/plugins/linux/virtualization.rb +2 -2
- data/lib/ohai/plugins/netbsd/network.rb +9 -9
- data/lib/ohai/plugins/network.rb +3 -3
- data/lib/ohai/plugins/openbsd/network.rb +9 -9
- data/lib/ohai/plugins/openstack.rb +2 -2
- data/lib/ohai/plugins/os.rb +1 -1
- data/lib/ohai/plugins/packages.rb +6 -8
- data/lib/ohai/plugins/passwd.rb +1 -1
- data/lib/ohai/plugins/scaleway.rb +2 -2
- data/lib/ohai/plugins/scsi.rb +1 -1
- data/lib/ohai/plugins/softlayer.rb +1 -1
- data/lib/ohai/plugins/solaris2/dmi.rb +2 -2
- data/lib/ohai/plugins/solaris2/network.rb +9 -9
- data/lib/ohai/plugins/solaris2/virtualization.rb +1 -1
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/virtualbox.rb +164 -19
- data/lib/ohai/plugins/windows/filesystem.rb +1 -1
- data/lib/ohai/plugins/windows/fips.rb +1 -1
- data/lib/ohai/plugins/windows/network.rb +3 -3
- data/lib/ohai/plugins/windows/virtualization.rb +2 -2
- data/lib/ohai/provides_map.rb +4 -4
- data/lib/ohai/runner.rb +1 -1
- data/lib/ohai/system.rb +15 -15
- data/lib/ohai/util/win32.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/solaris2/network_spec.rb +10 -1
- data/spec/unit/plugins/vbox_host_spec.rb +14 -0
- data/spec/unit/plugins/virtualbox_spec.rb +310 -23
- metadata +3 -2
| @@ -22,9 +22,9 @@ Ohai.plugin(:Network) do | |
| 22 22 |  | 
| 23 23 | 
             
              collect_data(:dragonflybsd) do
         | 
| 24 24 | 
             
                network Mash.new unless network
         | 
| 25 | 
            -
                network[:interfaces]  | 
| 25 | 
            +
                network[:interfaces] ||= Mash.new
         | 
| 26 26 | 
             
                counters Mash.new unless counters
         | 
| 27 | 
            -
                counters[:network]  | 
| 27 | 
            +
                counters[:network] ||= Mash.new
         | 
| 28 28 |  | 
| 29 29 | 
             
                so = shell_out("route -n get default")
         | 
| 30 30 | 
             
                so.stdout.lines do |line|
         | 
| @@ -52,11 +52,11 @@ Ohai.plugin(:Network) do | |
| 52 52 | 
             
                  end
         | 
| 53 53 | 
             
                  # call the family lladdr to match linux for consistency
         | 
| 54 54 | 
             
                  if line =~ /\s+ether (.+?)\s/
         | 
| 55 | 
            -
                    iface[cint][:addresses]  | 
| 55 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 56 56 | 
             
                    iface[cint][:addresses][$1] = { "family" => "lladdr" }
         | 
| 57 57 | 
             
                  end
         | 
| 58 58 | 
             
                  if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
         | 
| 59 | 
            -
                    iface[cint][:addresses]  | 
| 59 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 60 60 | 
             
                    # convert the netmask to decimal for consistency
         | 
| 61 61 | 
             
                    netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
         | 
| 62 62 | 
             
                    if $3.empty?
         | 
| @@ -67,7 +67,7 @@ Ohai.plugin(:Network) do | |
| 67 67 | 
             
                    end
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 | 
             
                  if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
         | 
| 70 | 
            -
                    iface[cint][:addresses]  | 
| 70 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 71 71 | 
             
                    if $4.empty?
         | 
| 72 72 | 
             
                      iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
         | 
| 73 73 | 
             
                    else
         | 
| @@ -89,7 +89,7 @@ Ohai.plugin(:Network) do | |
| 89 89 | 
             
                so.stdout.lines do |line|
         | 
| 90 90 | 
             
                  if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
         | 
| 91 91 | 
             
                    next unless iface[$3] # this should never happen
         | 
| 92 | 
            -
                    iface[$3][:arp]  | 
| 92 | 
            +
                    iface[$3][:arp] ||= Mash.new
         | 
| 93 93 | 
             
                    iface[$3][:arp][$1] = $2.downcase
         | 
| 94 94 | 
             
                  end
         | 
| 95 95 | 
             
                end
         | 
| @@ -107,9 +107,9 @@ Ohai.plugin(:Network) do | |
| 107 107 | 
             
                  # ed0    1500 <Link#1>      54:52:00:68:92:85   333604    26  151905886   175472     0   24897542     0  905
         | 
| 108 108 | 
             
                  # $1                        $2                      $3    $4         $5       $6    $7         $8    $9  $10
         | 
| 109 109 | 
             
                  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+)/
         | 
| 110 | 
            -
                    net_counters[$1]  | 
| 111 | 
            -
                    net_counters[$1]["rx"]  | 
| 112 | 
            -
                    net_counters[$1]["tx"]  | 
| 110 | 
            +
                    net_counters[$1] ||= Mash.new
         | 
| 111 | 
            +
                    net_counters[$1]["rx"] ||= Mash.new
         | 
| 112 | 
            +
                    net_counters[$1]["tx"] ||= Mash.new
         | 
| 113 113 | 
             
                    net_counters[$1]["rx"]["packets"] = $3
         | 
| 114 114 | 
             
                    net_counters[$1]["rx"]["errors"] = $4
         | 
| 115 115 | 
             
                    net_counters[$1]["rx"]["bytes"] = $5
         | 
    
        data/lib/ohai/plugins/ec2.rb
    CHANGED
    
    | @@ -26,8 +26,8 @@ | |
| 26 26 | 
             
            # 4. Kernel data mentioned Amazon. This catches Windows HVM & paravirt instances
         | 
| 27 27 |  | 
| 28 28 | 
             
            Ohai.plugin(:EC2) do
         | 
| 29 | 
            -
               | 
| 30 | 
            -
               | 
| 29 | 
            +
              require_relative "../mixin/ec2_metadata"
         | 
| 30 | 
            +
              require_relative "../mixin/http_helper"
         | 
| 31 31 | 
             
              require "base64"
         | 
| 32 32 |  | 
| 33 33 | 
             
              include Ohai::Mixin::Ec2Metadata
         | 
| @@ -19,8 +19,8 @@ | |
| 19 19 |  | 
| 20 20 | 
             
            Ohai.plugin(:Eucalyptus) do
         | 
| 21 21 | 
             
              # eucalyptus metadata service is compatible with the ec2 service calls
         | 
| 22 | 
            -
               | 
| 23 | 
            -
               | 
| 22 | 
            +
              require_relative "../mixin/ec2_metadata"
         | 
| 23 | 
            +
              require_relative "../mixin/http_helper"
         | 
| 24 24 |  | 
| 25 25 | 
             
              include Ohai::Mixin::Ec2Metadata
         | 
| 26 26 | 
             
              include Ohai::Mixin::HttpHelper
         | 
| @@ -65,7 +65,7 @@ Ohai.plugin(:Filesystem) do | |
| 65 65 | 
             
              def generate_device_view(fs)
         | 
| 66 66 | 
             
                view = {}
         | 
| 67 67 | 
             
                fs.each_value do |entry|
         | 
| 68 | 
            -
                  view[entry[:device]]  | 
| 68 | 
            +
                  view[entry[:device]] ||= Mash.new
         | 
| 69 69 | 
             
                  entry.each do |key, val|
         | 
| 70 70 | 
             
                    next if %w{device mount}.include?(key)
         | 
| 71 71 | 
             
                    view[entry[:device]][key] = val
         | 
| @@ -82,7 +82,7 @@ Ohai.plugin(:Filesystem) do | |
| 82 82 | 
             
                view = {}
         | 
| 83 83 | 
             
                fs.each_value do |entry|
         | 
| 84 84 | 
             
                  next unless entry[:mount]
         | 
| 85 | 
            -
                  view[entry[:mount]]  | 
| 85 | 
            +
                  view[entry[:mount]] ||= Mash.new
         | 
| 86 86 | 
             
                  entry.each do |key, val|
         | 
| 87 87 | 
             
                    next if %w{mount device}.include?(key)
         | 
| 88 88 | 
             
                    view[entry[:mount]][key] = val
         | 
| @@ -182,7 +182,7 @@ Ohai.plugin(:Filesystem) do | |
| 182 182 | 
             
                  so.stdout.each_line do |line|
         | 
| 183 183 | 
             
                    if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
         | 
| 184 184 | 
             
                      key = "#{$1},#{$2}"
         | 
| 185 | 
            -
                      fs[key]  | 
| 185 | 
            +
                      fs[key] ||= Mash.new
         | 
| 186 186 | 
             
                      fs[key][:device] = $1
         | 
| 187 187 | 
             
                      fs[key][:mount] = $2
         | 
| 188 188 | 
             
                      fs[key][:fs_type] = $3
         | 
| @@ -380,7 +380,7 @@ Ohai.plugin(:Filesystem) do | |
| 380 380 | 
             
                  so.stdout.lines do |line|
         | 
| 381 381 | 
             
                    if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
         | 
| 382 382 | 
             
                      key = "#{$1},#{$2}"
         | 
| 383 | 
            -
                      fs[key]  | 
| 383 | 
            +
                      fs[key] ||= Mash.new
         | 
| 384 384 | 
             
                      fs[key][:mount] = $2
         | 
| 385 385 | 
             
                      fs[key][:fs_type] = $3
         | 
| 386 386 | 
             
                      fs[key][:mount_options] = $4.split(/,\s*/)
         | 
| @@ -426,7 +426,7 @@ Ohai.plugin(:Filesystem) do | |
| 426 426 | 
             
                  so.stdout.lines do |line|
         | 
| 427 427 | 
             
                    next unless line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/
         | 
| 428 428 | 
             
                    key = "#{$2},#{$1}"
         | 
| 429 | 
            -
                    fs[key]  | 
| 429 | 
            +
                    fs[key] ||= Mash.new
         | 
| 430 430 | 
             
                    fs[key][:mount] = $1
         | 
| 431 431 | 
             
                    fs[key][:mount_time] = $4 # $4 must come before "split", else it becomes nil
         | 
| 432 432 | 
             
                    fs[key][:mount_options] = $3.split("/")
         | 
| @@ -22,9 +22,9 @@ Ohai.plugin(:Network) do | |
| 22 22 |  | 
| 23 23 | 
             
              collect_data(:freebsd) do
         | 
| 24 24 | 
             
                network Mash.new unless network
         | 
| 25 | 
            -
                network[:interfaces]  | 
| 25 | 
            +
                network[:interfaces] ||= Mash.new
         | 
| 26 26 | 
             
                counters Mash.new unless counters
         | 
| 27 | 
            -
                counters[:network]  | 
| 27 | 
            +
                counters[:network] ||= Mash.new
         | 
| 28 28 |  | 
| 29 29 | 
             
                so = shell_out("route -n get default")
         | 
| 30 30 | 
             
                so.stdout.lines do |line|
         | 
| @@ -52,11 +52,11 @@ Ohai.plugin(:Network) do | |
| 52 52 | 
             
                  end
         | 
| 53 53 | 
             
                  # call the family lladdr to match linux for consistency
         | 
| 54 54 | 
             
                  if line =~ /\s+ether (.+?)\s/
         | 
| 55 | 
            -
                    iface[cint][:addresses]  | 
| 55 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 56 56 | 
             
                    iface[cint][:addresses][$1] = { "family" => "lladdr" }
         | 
| 57 57 | 
             
                  end
         | 
| 58 58 | 
             
                  if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
         | 
| 59 | 
            -
                    iface[cint][:addresses]  | 
| 59 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 60 60 | 
             
                    # convert the netmask to decimal for consistency
         | 
| 61 61 | 
             
                    netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
         | 
| 62 62 | 
             
                    if $3.empty?
         | 
| @@ -67,7 +67,7 @@ Ohai.plugin(:Network) do | |
| 67 67 | 
             
                    end
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 | 
             
                  if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
         | 
| 70 | 
            -
                    iface[cint][:addresses]  | 
| 70 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 71 71 | 
             
                    if $4.empty?
         | 
| 72 72 | 
             
                      iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
         | 
| 73 73 | 
             
                    else
         | 
| @@ -89,7 +89,7 @@ Ohai.plugin(:Network) do | |
| 89 89 | 
             
                so.stdout.lines do |line|
         | 
| 90 90 | 
             
                  if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
         | 
| 91 91 | 
             
                    next unless iface[$3] # this should never happen
         | 
| 92 | 
            -
                    iface[$3][:arp]  | 
| 92 | 
            +
                    iface[$3][:arp] ||= Mash.new
         | 
| 93 93 | 
             
                    iface[$3][:arp][$1] = $2.downcase
         | 
| 94 94 | 
             
                  end
         | 
| 95 95 | 
             
                end
         | 
| @@ -107,9 +107,9 @@ Ohai.plugin(:Network) do | |
| 107 107 | 
             
                  # ed0    1500 <Link#1>      54:52:00:68:92:85   333604    26  151905886   175472     0   24897542     0  905
         | 
| 108 108 | 
             
                  # $1                        $2                      $3    $4         $5       $6    $7         $8    $9  $10
         | 
| 109 109 | 
             
                  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+)/
         | 
| 110 | 
            -
                    net_counters[$1]  | 
| 111 | 
            -
                    net_counters[$1]["rx"]  | 
| 112 | 
            -
                    net_counters[$1]["tx"]  | 
| 110 | 
            +
                    net_counters[$1] ||= Mash.new
         | 
| 111 | 
            +
                    net_counters[$1]["rx"] ||= Mash.new
         | 
| 112 | 
            +
                    net_counters[$1]["tx"] ||= Mash.new
         | 
| 113 113 | 
             
                    net_counters[$1]["rx"]["packets"] = $3
         | 
| 114 114 | 
             
                    net_counters[$1]["rx"]["errors"] = $4
         | 
| 115 115 | 
             
                    net_counters[$1]["rx"]["bytes"] = $5
         | 
    
        data/lib/ohai/plugins/gce.rb
    CHANGED
    
    | @@ -15,8 +15,8 @@ | |
| 15 15 | 
             
            # limitations under the License.
         | 
| 16 16 |  | 
| 17 17 | 
             
            Ohai.plugin(:GCE) do
         | 
| 18 | 
            -
               | 
| 19 | 
            -
               | 
| 18 | 
            +
              require_relative "../mixin/gce_metadata"
         | 
| 19 | 
            +
              require_relative "../mixin/http_helper"
         | 
| 20 20 |  | 
| 21 21 | 
             
              include Ohai::Mixin::GCEMetadata
         | 
| 22 22 | 
             
              include Ohai::Mixin::HttpHelper
         | 
| @@ -26,7 +26,7 @@ | |
| 26 26 | 
             
            #
         | 
| 27 27 |  | 
| 28 28 | 
             
            Ohai.plugin(:Hostname) do
         | 
| 29 | 
            -
              require "socket"
         | 
| 29 | 
            +
              require "socket" unless defined?(Socket)
         | 
| 30 30 | 
             
              require "ipaddr"
         | 
| 31 31 |  | 
| 32 32 | 
             
              provides "domain", "hostname", "fqdn", "machinename"
         | 
| @@ -161,7 +161,7 @@ Ohai.plugin(:Hostname) do | |
| 161 161 |  | 
| 162 162 | 
             
              collect_data(:windows) do
         | 
| 163 163 | 
             
                require "wmi-lite/wmi"
         | 
| 164 | 
            -
                require "socket"
         | 
| 164 | 
            +
                require "socket" unless defined?(Socket)
         | 
| 165 165 |  | 
| 166 166 | 
             
                wmi = WmiLite::Wmi.new
         | 
| 167 167 | 
             
                host = wmi.first_of("Win32_ComputerSystem")
         | 
    
        data/lib/ohai/plugins/kernel.rb
    CHANGED
    
    
| @@ -28,7 +28,7 @@ Ohai.plugin(:Fips) do | |
| 28 28 | 
             
              collect_data(:linux) do
         | 
| 29 29 | 
             
                fips Mash.new
         | 
| 30 30 |  | 
| 31 | 
            -
                require "openssl"
         | 
| 31 | 
            +
                require "openssl" unless defined?(OpenSSL)
         | 
| 32 32 | 
             
                if defined?(OpenSSL.fips_mode) && OpenSSL.fips_mode && !$FIPS_TEST_MODE
         | 
| 33 33 | 
             
                  fips["kernel"] = { "enabled" => true }
         | 
| 34 34 | 
             
                else
         | 
| @@ -58,7 +58,7 @@ Ohai.plugin(:Network) do | |
| 58 58 | 
             
                      logger.warn("neighbor list has entries for unknown interface #{interface}")
         | 
| 59 59 | 
             
                      next
         | 
| 60 60 | 
             
                    end
         | 
| 61 | 
            -
                    interface[neigh_attr]  | 
| 61 | 
            +
                    interface[neigh_attr] ||= Mash.new
         | 
| 62 62 | 
             
                    interface[neigh_attr][$1] = $3.downcase
         | 
| 63 63 | 
             
                  end
         | 
| 64 64 | 
             
                end
         | 
| @@ -208,8 +208,8 @@ Ohai.plugin(:Network) do | |
| 208 208 | 
             
                so.stdout.lines do |line|
         | 
| 209 209 | 
             
                  if line =~ IPROUTE_INT_REGEX
         | 
| 210 210 | 
             
                    tmp_int = $2
         | 
| 211 | 
            -
                    iface[tmp_int]  | 
| 212 | 
            -
                    net_counters[tmp_int]  | 
| 211 | 
            +
                    iface[tmp_int] ||= Mash.new
         | 
| 212 | 
            +
                    net_counters[tmp_int] ||= Mash.new
         | 
| 213 213 | 
             
                  end
         | 
| 214 214 |  | 
| 215 215 | 
             
                  if line =~ /^\s+(ip6tnl|ipip)/
         | 
| @@ -239,7 +239,7 @@ Ohai.plugin(:Network) do | |
| 239 239 |  | 
| 240 240 | 
             
                  if line =~ /(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
         | 
| 241 241 | 
             
                    int = on_rx ? :rx : :tx
         | 
| 242 | 
            -
                    net_counters[tmp_int][int]  | 
| 242 | 
            +
                    net_counters[tmp_int][int] ||= Mash.new
         | 
| 243 243 | 
             
                    net_counters[tmp_int][int][:bytes] = $1
         | 
| 244 244 | 
             
                    net_counters[tmp_int][int][:packets] = $2
         | 
| 245 245 | 
             
                    net_counters[tmp_int][int][:errors] = $3
         | 
| @@ -255,7 +255,7 @@ Ohai.plugin(:Network) do | |
| 255 255 | 
             
                  end
         | 
| 256 256 |  | 
| 257 257 | 
             
                  if line =~ /qlen (\d+)/
         | 
| 258 | 
            -
                    net_counters[tmp_int][:tx]  | 
| 258 | 
            +
                    net_counters[tmp_int][:tx] ||= Mash.new
         | 
| 259 259 | 
             
                    net_counters[tmp_int][:tx][:queuelen] = $1
         | 
| 260 260 | 
             
                  end
         | 
| 261 261 |  | 
| @@ -266,7 +266,7 @@ Ohai.plugin(:Network) do | |
| 266 266 | 
             
                    else
         | 
| 267 267 | 
             
                      tmp_id = $1
         | 
| 268 268 | 
             
                    end
         | 
| 269 | 
            -
                    iface[tmp_int][:vlan]  | 
| 269 | 
            +
                    iface[tmp_int][:vlan] ||= Mash.new
         | 
| 270 270 | 
             
                    iface[tmp_int][:vlan][:id] = tmp_id
         | 
| 271 271 | 
             
                    iface[tmp_int][:vlan][:protocol] = tmp_prot if tmp_prot
         | 
| 272 272 |  | 
| @@ -320,7 +320,7 @@ Ohai.plugin(:Network) do | |
| 320 320 | 
             
                if line =~ /link\/(\w+) ([\da-f\:]+) /
         | 
| 321 321 | 
             
                  iface[cint][:encapsulation] = linux_encaps_lookup($1)
         | 
| 322 322 | 
             
                  unless $2 == "00:00:00:00:00:00"
         | 
| 323 | 
            -
                    iface[cint][:addresses]  | 
| 323 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 324 324 | 
             
                    iface[cint][:addresses][$2.upcase] = { "family" => "lladdr" }
         | 
| 325 325 | 
             
                  end
         | 
| 326 326 | 
             
                end
         | 
| @@ -340,8 +340,8 @@ Ohai.plugin(:Network) do | |
| 340 340 | 
             
                    cint = alias_int
         | 
| 341 341 | 
             
                  end
         | 
| 342 342 |  | 
| 343 | 
            -
                  iface[cint]  | 
| 344 | 
            -
                  iface[cint][:addresses]  | 
| 343 | 
            +
                  iface[cint] ||= Mash.new # Create the fake alias interface if needed
         | 
| 344 | 
            +
                  iface[cint][:addresses] ||= Mash.new
         | 
| 345 345 | 
             
                  iface[cint][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
         | 
| 346 346 | 
             
                  iface[cint][:addresses][tmp_addr][:netmask] = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
         | 
| 347 347 |  | 
| @@ -365,7 +365,7 @@ Ohai.plugin(:Network) do | |
| 365 365 |  | 
| 366 366 | 
             
              def parse_ip_addr_inet6_line(cint, iface, line)
         | 
| 367 367 | 
             
                if line =~ /inet6 ([a-f0-9\:]+)\/(\d+) scope (\w+)( .*)?/
         | 
| 368 | 
            -
                  iface[cint][:addresses]  | 
| 368 | 
            +
                  iface[cint][:addresses] ||= Mash.new
         | 
| 369 369 | 
             
                  tmp_addr = $1
         | 
| 370 370 | 
             
                  tags = $4 || ""
         | 
| 371 371 | 
             
                  tags = tags.split(" ")
         | 
| @@ -476,9 +476,9 @@ Ohai.plugin(:Network) do | |
| 476 476 | 
             
                net_counters = Mash.new
         | 
| 477 477 |  | 
| 478 478 | 
             
                network Mash.new unless network
         | 
| 479 | 
            -
                network[:interfaces]  | 
| 479 | 
            +
                network[:interfaces] ||= Mash.new
         | 
| 480 480 | 
             
                counters Mash.new unless counters
         | 
| 481 | 
            -
                counters[:network]  | 
| 481 | 
            +
                counters[:network] ||= Mash.new
         | 
| 482 482 |  | 
| 483 483 | 
             
                # ohai.plugin[:network][:default_route_table] = 'default'
         | 
| 484 484 | 
             
                if configuration(:default_route_table).nil? || configuration(:default_route_table).empty?
         | 
| @@ -491,7 +491,7 @@ Ohai.plugin(:Network) do | |
| 491 491 | 
             
                # Match the lead line for an interface from iproute2
         | 
| 492 492 | 
             
                # 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
         | 
| 493 493 | 
             
                # The '@eth0:' portion doesn't exist on primary interfaces and thus is optional in the regex
         | 
| 494 | 
            -
                IPROUTE_INT_REGEX  | 
| 494 | 
            +
                IPROUTE_INT_REGEX ||= /^(\d+): ([0-9a-zA-Z@:\.\-_]*?)(@[0-9a-zA-Z]+|):\s/.freeze
         | 
| 495 495 |  | 
| 496 496 | 
             
                if which("ip")
         | 
| 497 497 | 
             
                  # families to get default routes from
         | 
| @@ -597,16 +597,16 @@ Ohai.plugin(:Network) do | |
| 597 597 | 
             
                      iface[cint][:encapsulation] = linux_encaps_lookup($1)
         | 
| 598 598 | 
             
                    end
         | 
| 599 599 | 
             
                    if line =~ /HWaddr (.+?)\s/
         | 
| 600 | 
            -
                      iface[cint][:addresses]  | 
| 600 | 
            +
                      iface[cint][:addresses] ||= Mash.new
         | 
| 601 601 | 
             
                      iface[cint][:addresses][$1] = { "family" => "lladdr" }
         | 
| 602 602 | 
             
                    end
         | 
| 603 603 | 
             
                    if line =~ /inet addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
         | 
| 604 | 
            -
                      iface[cint][:addresses]  | 
| 604 | 
            +
                      iface[cint][:addresses] ||= Mash.new
         | 
| 605 605 | 
             
                      iface[cint][:addresses][$1] = { "family" => "inet" }
         | 
| 606 606 | 
             
                      tmp_addr = $1
         | 
| 607 607 | 
             
                    end
         | 
| 608 608 | 
             
                    if line =~ /inet6 addr: ([a-f0-9\:]+)\/(\d+) Scope:(\w+)/
         | 
| 609 | 
            -
                      iface[cint][:addresses]  | 
| 609 | 
            +
                      iface[cint][:addresses] ||= Mash.new
         | 
| 610 610 | 
             
                      iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $2, "scope" => ($3.eql?("Host") ? "Node" : $3) }
         | 
| 611 611 | 
             
                    end
         | 
| 612 612 | 
             
                    if line =~ /Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
         | 
| @@ -626,7 +626,7 @@ Ohai.plugin(:Network) do | |
| 626 626 | 
             
                      iface[cint][:peer] = $1
         | 
| 627 627 | 
             
                    end
         | 
| 628 628 | 
             
                    if line =~ /RX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) frame:(\d+)/
         | 
| 629 | 
            -
                      net_counters[cint]  | 
| 629 | 
            +
                      net_counters[cint] ||= Mash.new
         | 
| 630 630 | 
             
                      net_counters[cint][:rx] = { "packets" => $1, "errors" => $2, "drop" => $3, "overrun" => $4, "frame" => $5 }
         | 
| 631 631 | 
             
                    end
         | 
| 632 632 | 
             
                    if line =~ /TX packets:(\d+) errors:(\d+) dropped:(\d+) overruns:(\d+) carrier:(\d+)/
         | 
| @@ -650,7 +650,7 @@ Ohai.plugin(:Network) do | |
| 650 650 | 
             
                  so.stdout.lines do |line|
         | 
| 651 651 | 
             
                    if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) \[(\w+)\] on ([0-9a-zA-Z\.\:\-]+)/
         | 
| 652 652 | 
             
                      next unless iface[$4] # this should never happen
         | 
| 653 | 
            -
                      iface[$4][:arp]  | 
| 653 | 
            +
                      iface[$4][:arp] ||= Mash.new
         | 
| 654 654 | 
             
                      iface[$4][:arp][$1] = $2.downcase
         | 
| 655 655 | 
             
                    end
         | 
| 656 656 | 
             
                  end
         | 
| @@ -23,8 +23,7 @@ Ohai.plugin(:Platform) do | |
| 23 23 | 
             
              # the platform mappings between the 'ID' field in /etc/os-release and the value
         | 
| 24 24 | 
             
              # ohai uses. If you're adding a new platform here and you want to change the name
         | 
| 25 25 | 
             
              # you'll want to add it here and then add a spec for the platform_id_remap method
         | 
| 26 | 
            -
               | 
| 27 | 
            -
                PLATFORM_MAPPINGS = {
         | 
| 26 | 
            +
              PLATFORM_MAPPINGS ||= {
         | 
| 28 27 | 
             
                  "rhel" => "redhat",
         | 
| 29 28 | 
             
                  "amzn" => "amazon",
         | 
| 30 29 | 
             
                  "ol" => "oracle",
         | 
| @@ -34,7 +33,6 @@ Ohai.plugin(:Platform) do | |
| 34 33 | 
             
                  "xenenterprise" => "xenserver",
         | 
| 35 34 | 
             
                  "cumulus-linux" => "cumulus",
         | 
| 36 35 | 
             
                }.freeze
         | 
| 37 | 
            -
              end
         | 
| 38 36 |  | 
| 39 37 | 
             
              # @deprecated
         | 
| 40 38 | 
             
              def get_redhatish_platform(contents)
         | 
| @@ -28,8 +28,8 @@ Ohai.plugin(:Sessions) do | |
| 28 28 | 
             
                  loginctl = shell_out(cmd)
         | 
| 29 29 |  | 
| 30 30 | 
             
                  sessions Mash.new unless sessions
         | 
| 31 | 
            -
                  sessions[:by_session]  | 
| 32 | 
            -
                  sessions[:by_user]  | 
| 31 | 
            +
                  sessions[:by_session] ||= Mash.new
         | 
| 32 | 
            +
                  sessions[:by_user] ||= Mash.new
         | 
| 33 33 |  | 
| 34 34 | 
             
                  loginctl.stdout.split("\n").each do |line|
         | 
| 35 35 | 
             
                    session, uid, user, seat = line.split
         | 
| @@ -19,7 +19,7 @@ | |
| 19 19 | 
             
            Ohai.plugin(:Virtualization) do
         | 
| 20 20 | 
             
              provides "virtualization"
         | 
| 21 21 | 
             
              depends "dmi"
         | 
| 22 | 
            -
               | 
| 22 | 
            +
              require_relative "../../mixin/dmi_decode"
         | 
| 23 23 | 
             
              include Ohai::Mixin::DmiDecode
         | 
| 24 24 |  | 
| 25 25 | 
             
              def lxc_version_exists?
         | 
| @@ -36,7 +36,7 @@ Ohai.plugin(:Virtualization) do | |
| 36 36 |  | 
| 37 37 | 
             
              collect_data(:linux) do
         | 
| 38 38 | 
             
                virtualization Mash.new unless virtualization
         | 
| 39 | 
            -
                virtualization[:systems]  | 
| 39 | 
            +
                virtualization[:systems] ||= Mash.new
         | 
| 40 40 |  | 
| 41 41 | 
             
                # Docker hosts
         | 
| 42 42 | 
             
                if docker_exists?
         | 
| @@ -22,9 +22,9 @@ Ohai.plugin(:Network) do | |
| 22 22 |  | 
| 23 23 | 
             
              collect_data(:netbsd) do
         | 
| 24 24 | 
             
                network Mash.new unless network
         | 
| 25 | 
            -
                network[:interfaces]  | 
| 25 | 
            +
                network[:interfaces] ||= Mash.new
         | 
| 26 26 | 
             
                counters Mash.new unless counters
         | 
| 27 | 
            -
                counters[:network]  | 
| 27 | 
            +
                counters[:network] ||= Mash.new
         | 
| 28 28 |  | 
| 29 29 | 
             
                so = shell_out("route -n get default")
         | 
| 30 30 | 
             
                so.stdout.lines do |line|
         | 
| @@ -52,11 +52,11 @@ Ohai.plugin(:Network) do | |
| 52 52 | 
             
                  end
         | 
| 53 53 | 
             
                  # call the family lladdr to match linux for consistency
         | 
| 54 54 | 
             
                  if line =~ /\s+address: (.+?)\s/
         | 
| 55 | 
            -
                    iface[cint][:addresses]  | 
| 55 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 56 56 | 
             
                    iface[cint][:addresses][$1] = { "family" => "lladdr" }
         | 
| 57 57 | 
             
                  end
         | 
| 58 58 | 
             
                  if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
         | 
| 59 | 
            -
                    iface[cint][:addresses]  | 
| 59 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 60 60 | 
             
                    # convert the netmask to decimal for consistency
         | 
| 61 61 | 
             
                    netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
         | 
| 62 62 | 
             
                    if $3.empty?
         | 
| @@ -67,7 +67,7 @@ Ohai.plugin(:Network) do | |
| 67 67 | 
             
                    end
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 | 
             
                  if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
         | 
| 70 | 
            -
                    iface[cint][:addresses]  | 
| 70 | 
            +
                    iface[cint][:addresses] ||= Mash.new
         | 
| 71 71 | 
             
                    if $4.empty?
         | 
| 72 72 | 
             
                      iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
         | 
| 73 73 | 
             
                    else
         | 
| @@ -89,7 +89,7 @@ Ohai.plugin(:Network) do | |
| 89 89 | 
             
                so.stdout.lines do |line|
         | 
| 90 90 | 
             
                  if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
         | 
| 91 91 | 
             
                    next unless iface[$3] # this should never happen
         | 
| 92 | 
            -
                    iface[$3][:arp]  | 
| 92 | 
            +
                    iface[$3][:arp] ||= Mash.new
         | 
| 93 93 | 
             
                    iface[$3][:arp][$1] = $2.downcase
         | 
| 94 94 | 
             
                  end
         | 
| 95 95 | 
             
                end
         | 
| @@ -107,9 +107,9 @@ Ohai.plugin(:Network) do | |
| 107 107 | 
             
                  # em0     1500  <Link>      00:11:25:2d:90:be  3719557     0  3369969     0     0    0
         | 
| 108 108 | 
             
                  # $1                        $2                      $3    $4    $5       $6    $7   $8
         | 
| 109 109 | 
             
                  if line =~ /^([\w\.\*]+)\s+\d+\s+<Link>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
         | 
| 110 | 
            -
                    net_counters[$1]  | 
| 111 | 
            -
                    net_counters[$1]["rx"]  | 
| 112 | 
            -
                    net_counters[$1]["tx"]  | 
| 110 | 
            +
                    net_counters[$1] ||= Mash.new
         | 
| 111 | 
            +
                    net_counters[$1]["rx"] ||= Mash.new
         | 
| 112 | 
            +
                    net_counters[$1]["tx"] ||= Mash.new
         | 
| 113 113 | 
             
                    net_counters[$1]["rx"]["packets"] = $3
         | 
| 114 114 | 
             
                    net_counters[$1]["rx"]["errors"] = $4
         | 
| 115 115 | 
             
                    net_counters[$1]["tx"]["packets"] = $5
         |