Module: Yast::PartitioningLvmPvLibInclude

Defined in:
../../src/include/partitioning/lvm_pv_lib.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) addPhysicalVolume(targetMap, id, current_vg)

used by autoyast



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File '../../src/include/partitioning/lvm_pv_lib.rb', line 50

def addPhysicalVolume(targetMap, id, current_vg)
  targetMap = deep_copy(targetMap)
  partition = Storage.GetPartition(targetMap, id)
  Builtins.y2milestone("partition %1", partition)

  if Ops.get_integer(partition, "fsid", 0) != Partitions.fsid_lvm &&
      Builtins.contains(
        [:primary, :logical],
        Ops.get_symbol(partition, "type", :none)
      )
    Storage.SetPartitionId(id, Partitions.fsid_lvm)
  end
  Storage.SetPartitionMount(id, "")
  Storage.SetPartitionFormat(id, false, :none)
  ret = Storage.ExtendLvmVg(current_vg, id)
  ret
end

- (Object) check_vgname_dev(vgname)



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File '../../src/include/partitioning/lvm_pv_lib.rb', line 167

def check_vgname_dev(vgname)
  ret = true
  devdir = Ops.add("/dev/", vgname)
  stat = Convert.to_map(SCR.Read(path(".target.stat"), devdir))
  Builtins.y2milestone("check_vgname_dev stat %1", stat)
  if Ops.greater_than(Builtins.size(stat), 0)
    ret = Ops.get_boolean(stat, "isdir", false)
    if ret
      out = Convert.to_map(
        SCR.Execute(
          path(".target.bash_output"),
          Ops.add(Ops.add("find ", devdir), " ! -type l | sed 1d")
        )
      )
      ret = Builtins.size(Ops.get_string(out, "stdout", "")) == 0
    end
  end
  Builtins.y2milestone("check_vgname_dev %1 ret %2", vgname, ret)
  ret
end

- (Object) get_possible_pvs(targetMap)

/////////////////////////////////////////////////////////////// Get all partitions, we can probably use as physical volumes Add needed information: disksize



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File '../../src/include/partitioning/lvm_pv_lib.rb', line 72

def get_possible_pvs(targetMap)
  targetMap = deep_copy(targetMap)
  ret = []

  #////////////////////////////////////////////////////////////////////
  # add the devicename i.e /dev/hda1 or /dev/system/usr to partition list
  # and the device key  <subdevice>/<maindevice> i.e. 1//dev/hda

  targetMap = Builtins.mapmap(targetMap) do |dev, devmap|
    partitions = Builtins.maplist(Ops.get_list(devmap, "partitions", [])) do |part|
      Ops.set(part, "maindev", dev)
      deep_copy(part)
    end
    { dev => Builtins.add(devmap, "partitions", partitions) }
  end

  #//////////////////////////////////////////////////////////
  # Look for all partitions:
  # not LVM ( here I mean /dev/<lvm_volumegroup>/<lv> entries!
  #           there are only the lv's in the targetMap under /dev/<lvm_volumegroup>/<lv> !)
  # no mountpoint
  # id 0x83 or 0x8e or 0xfe

  types_no = [:lvm, :extended]
  fsids = [
    Partitions.fsid_lvm,
    Partitions.fsid_raid,
    Partitions.fsid_native
  ]
  allowed_enc_types = [:none, :luks]

  Builtins.foreach(targetMap) do |dev, devmap|
    Builtins.y2milestone(
      "get_possible_pvs parts:%1",
      Ops.get_list(devmap, "partitions", [])
    )
    parts = Builtins.filter(Ops.get_list(devmap, "partitions", [])) do |part|
      Builtins.size(Ops.get_string(part, "mount", "")) == 0 &&
        !Builtins.contains(types_no, Ops.get_symbol(part, "type", :primary)) &&
        Builtins.contains(
          allowed_enc_types,
          Ops.get_symbol(part, "enc_type", :none)
        ) &&
        (!Storage.IsUsedBy(part) ||
          Ops.get_symbol(part, "used_by_type", :UB_NONE) == :UB_LVM) &&
        (Ops.get_symbol(part, "type", :primary) == :sw_raid ||
          Ops.get_symbol(part, "type", :primary) == :dm ||
          Builtins.contains(fsids, Ops.get_integer(part, "fsid", 0)))
    end
    Builtins.y2milestone("get_possible_pvs filter:%1", parts)
    if Ops.get_symbol(devmap, "used_by_type", :UB_NONE) != :UB_NONE
      parts = []
      Builtins.y2milestone(
        "get_possible_pvs no parts, disk used by %1 %2",
        Ops.get_symbol(devmap, "used_by_type", :UB_NONE),
        Ops.get_string(devmap, "used_by_device", "")
      )
    end
    if Builtins.size(Ops.get_list(devmap, "partitions", [])) == 0 &&
        Storage.IsPartType(Ops.get_symbol(devmap, "type", :CT_UNKNOWN)) &&
        (!Storage.IsUsedBy(devmap) ||
          Ops.get_symbol(devmap, "used_by_type", :UB_NONE) == :UB_LVM)
      p = {
        "device"  => dev,
        "maindev" => dev,
        "size_k"  => Ops.get_integer(devmap, "size_k", 0)
      }
      if Ops.get_symbol(devmap, "used_by_type", :UB_NONE) != :UB_NONE
        Ops.set(
          p,
          "used_by_type",
          Ops.get_symbol(devmap, "used_by_type", :UB_NONE)
        )
        Ops.set(
          p,
          "used_by_device",
          Ops.get_string(devmap, "used_by_device", "")
        )
      end
      if Builtins.haskey(devmap, "used_by")
        Ops.set(p, "used_by", Ops.get_list(devmap, "used_by", []))
      end
      parts = [p]
    end
    ret = Convert.convert(
      Builtins.merge(ret, parts),
      :from => "list",
      :to   => "list <map>"
    )
  end
  Builtins.y2milestone("get_possible_pvs ret %1", ret)
  deep_copy(ret)
end

- (Object) initialize_partitioning_lvm_pv_lib(include_target)



28
29
30
31
32
33
34
35
# File '../../src/include/partitioning/lvm_pv_lib.rb', line 28

def initialize_partitioning_lvm_pv_lib(include_target)
  textdomain "storage"
  Yast.import "Storage"
  Yast.import "Partitions"

  Yast.include include_target, "partitioning/lvm_lib.rb"
  Yast.include include_target, "partitioning/lvm_lv_lib.rb"
end