class CFA::Grub2::DeviceMap

Represents grub device map in /boot/grub2/device_map for details see www.gnu.org/software/grub/manual/html_node/Device-map.html Main features:

Constants

PATH

Public Class Methods

new(file_handler: nil) click to toggle source
Calls superclass method
# File lib/cfa/grub2/device_map.rb, line 23
def initialize(file_handler: nil)
  super(AugeasParser.new("device_map.lns"), PATH,
    file_handler: file_handler)
end

Public Instance Methods

add_mapping(grub_device, system_device) click to toggle source

Appends to configuration mapping between grub_device and system_device @note if mapping for given grub device is already defined, it will be

overwritten
# File lib/cfa/grub2/device_map.rb, line 50
def add_mapping(grub_device, system_device)
  generic_set(grub_device, system_device)
end
grub_device_for(system_dev) click to toggle source

@return [String] grub device name for given system device

# File lib/cfa/grub2/device_map.rb, line 35
def grub_device_for(system_dev)
  matcher = Matcher.new(value_matcher: system_dev)
  entry = data.select(matcher)

  entry.empty? ? nil : entry.first[:key]
end
grub_devices() click to toggle source

@return [Array<String>] list of all grub devices which have mapping.

If there is no mapping, then it return empty list.
# File lib/cfa/grub2/device_map.rb, line 61
def grub_devices
  matcher = Matcher.new { |k, _v| k !~ /comment/ }
  entries = data.select(matcher)

  entries.map { |e| e[:key] }
end
remove_mapping(grub_device) click to toggle source

Removes mapping for given grub device

# File lib/cfa/grub2/device_map.rb, line 55
def remove_mapping(grub_device)
  data.delete(grub_device)
end
save() click to toggle source
Calls superclass method
# File lib/cfa/grub2/device_map.rb, line 28
def save
  raise "Too many grub devices. Limit is 8." if grub_devices.size > 8

  super
end
system_device_for(grub_device) click to toggle source

@return [String] system device name for given grub device

# File lib/cfa/grub2/device_map.rb, line 43
def system_device_for(grub_device)
  data[grub_device]
end