lib/ohai/plugins/linux/filesystem2.rb in ohai-8.10.0 vs lib/ohai/plugins/linux/filesystem2.rb in ohai-8.11.1

- old
+ new

@@ -32,20 +32,20 @@ def parse_line(line, have_lsblk) if have_lsblk 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 key = :fs_type if key == :type f[key] = $2 @@ -59,11 +59,11 @@ def generate_device_view(fs) view = {} 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] ||= [] if entry[:mount] view[entry[:device]][:mounts] << entry[:mount] @@ -76,11 +76,11 @@ view = {} fs.each_value do |entry| 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] ||= [] if entry[:device] view[entry[:mount]][:devices] << entry[:device] @@ -139,16 +139,16 @@ fs[key][:fs_type] = $3 fs[key][:mount_options] = $4.split(",") 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) so.stdout.each_line do |line| parsed = parse_line(line, have_lsblk) @@ -175,15 +175,15 @@ end 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) mounts << data # We should just catch EOFError, but the kernel had a period of @@ -211,12 +211,12 @@ by_pair = fs by_device = generate_device_view(fs) 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 end end