Class: Bootloader::DeviceMap

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Yast::Logger
Defined in:
src/lib/bootloader/device_map.rb

Overview

Class representing grub device map structure

Instance Method Summary collapse

Constructor Details

#initializeDeviceMap

Returns a new instance of DeviceMap.


21
22
23
24
25
26
27
# File 'src/lib/bootloader/device_map.rb', line 21

def initialize
  # lazy load to avoid circular dependencies
  Yast.import "Arch"
  Yast.import "BootStorage"
  Yast.import "Mode"
  @model = CFA::Grub2::DeviceMap.new
end

Instance Method Details

#clear_mappingObject


50
51
52
53
54
# File 'src/lib/bootloader/device_map.rb', line 50

def clear_mapping
  grub_devices.each do |grub_dev|
    remove_mapping(grub_dev)
  end
end

#contain_disk?(disk) ⇒ Boolean

Returns:

  • (Boolean)

56
57
58
59
60
61
# File 'src/lib/bootloader/device_map.rb', line 56

def contain_disk?(disk)
  disk = grub_device_for(disk) ||
    grub_device_for(::Bootloader::UdevMapping.to_mountby_device(disk))

  !disk.nil?
end

#disks_orderObject


63
64
65
# File 'src/lib/bootloader/device_map.rb', line 63

def disks_order
  sorted_disks.map { |d| system_device_for(d) }
end

#empty?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'src/lib/bootloader/device_map.rb', line 46

def empty?
  size == 0
end

#proposeObject


67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'src/lib/bootloader/device_map.rb', line 67

def propose
  @model = CFA::Grub2::DeviceMap.new

  if Yast::Mode.config
    log.info("Skipping device map proposing in Config mode")
    return
  end

  fill_mapping

  order_boot_device

  reduce_to_bios_limit
end

#readObject


33
34
35
# File 'src/lib/bootloader/device_map.rb', line 33

def read
  @model.load
end

#sizeObject


42
43
44
# File 'src/lib/bootloader/device_map.rb', line 42

def size
  grub_devices.size
end

#to_hashObject


82
83
84
# File 'src/lib/bootloader/device_map.rb', line 82

def to_hash
  grub_devices.each_with_object({}) { |k, r| r[k] = system_device_for(k) }
end

#to_sObject


29
30
31
# File 'src/lib/bootloader/device_map.rb', line 29

def to_s
  "Device Map: #{to_hash}"
end

#writeObject


37
38
39
40
# File 'src/lib/bootloader/device_map.rb', line 37

def write
  log.info "writing device map: #{self}"
  @model.save
end