Class: Yast::AutoinstRAIDClass
- Inherits:
-
Module
- Object
- Module
- Yast::AutoinstRAIDClass
- Defined in:
- ../../src/modules/AutoinstRAID.rb
Instance Method Summary (collapse)
-
- (void) AutoinstRAID
Constructor.
-
- (Array) ExistingMDs(md)
Return existing MDs.
-
- (Object) Init
Initialize.
- - (Object) main
- - (Object) remove_possible_mds
-
- (Boolean) Write
Create RAID Configuration.
Instance Method Details
- (void) AutoinstRAID
This method returns an undefined value.
Constructor
41 42 43 |
# File '../../src/modules/AutoinstRAID.rb', line 41 def AutoinstRAID nil end |
- (Array) ExistingMDs(md)
Return existing MDs
65 66 67 68 69 |
# File '../../src/modules/AutoinstRAID.rb', line 65 def ExistingMDs(md) Builtins.filter(get_possible_rds(Storage.GetTargetMap)) do |part| Ops.get_string(part, "raid_name", "-1") == md end end |
- (Object) Init
Initialize
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File '../../src/modules/AutoinstRAID.rb', line 46 def Init @raid = Builtins.filter(AutoinstStorage.AutoTargetMap) do |k, v| k == "/dev/md" end return false if Builtins.size(@raid) == 0 @ExistingRAID = Builtins.filter(Storage.GetTargetMap) do |k, v| k == "/dev/md" end Builtins.y2milestone("Existing RAID: %1", @ExistingRAID) @old_available = true if Ops.greater_than(Builtins.size(@ExistingRAID), 0) true end |
- (Object) main
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File '../../src/modules/AutoinstRAID.rb', line 13 def main textdomain "autoinst" Yast.import "Storage" Yast.import "Partitions" Yast.import "AutoinstStorage" Yast.include self, "partitioning/raid_lib.rb" @ExistingRAID = {} @old_available = false @raid = {} # Local variables @region = [0, 0] # Temporary copy of variable from Storage @targetMap = {} AutoinstRAID() end |
- (Object) remove_possible_mds
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 |
# File '../../src/modules/AutoinstRAID.rb', line 133 def remove_possible_mds prefer_remove = Ops.get_boolean( @raid, ["/dev/md", "prefer_remove"], false ) if @old_available && prefer_remove existing_mds = Ops.get_list( @ExistingRAID, ["/dev/md", "partitions"], [] ) modified_mds = Builtins.maplist(existing_mds) do |md| Ops.set(md, "delete", true) deep_copy(md) end allmds = Convert.convert( Ops.get(@ExistingRAID, "/dev/md", {}), :from => "map", :to => "map <string, any>" ) Ops.set(allmds, "partitions", modified_mds) tg = Storage.GetTargetMap Ops.set(tg, "/dev/md", allmds) Storage.SetTargetMap(tg) # update our variable Ops.set(@ExistingRAID, "/dev/md", allmds) end true end |
- (Boolean) Write
Create RAID Configuration
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File '../../src/modules/AutoinstRAID.rb', line 166 def Write remove_possible_mds raid_partitions = Ops.get_list(@raid, ["/dev/md", "partitions"], []) _RaidList = Builtins.maplist(raid_partitions) do |md| use = Ops.get_string(@raid, ["/dev/md", "use"], "none") dev = md.fetch("raid_options",{})["raid_name"] if !dev || dev.empty? dev = "/dev/md"+md.fetch("partition_nr", 0).to_s end md["device"] = dev if Ops.get_symbol(md, "enc_type", :none) != :none Storage.SetCryptPwd(dev, Ops.get_string(md, "crypt_key", "")) end Builtins.y2milestone("Working on %1", md) chunk_size = 4 = Ops.get_map(md, "raid_options", {}) raid_type = Ops.get_string(, "raid_type", "raid1") chunk_size = 128 if raid_type == "raid5" chunk_size = 32 if raid_type == "raid0" if !Builtins.haskey(, "raid_type") Ops.set(, "raid_type", raid_type) end sel_chunksize = Builtins.tointeger( Ops.get_string(, "chunk_size", "0") ) if sel_chunksize != 0 chunk_size = sel_chunksize Ops.set(, "chunk_size", chunk_size) end if raid_type == "raid5" && Ops.get_string(, "parity_algorithm", "") == "" Ops.set(, "parity_algorithm", "left_symmetric") end Ops.set(md, "nr", Ops.get_integer(md, "partition_nr", 0)) if !Builtins.haskey(md, "create") Ops.set(md, "create", true) Ops.set(md, "status", "create") end Ops.set(md, "format", false) if !Builtins.haskey(md, "format") if Ops.get_boolean(md, "format", false) Ops.set(md, "used_fs", Ops.get_symbol(md, "filesystem", Partitions.DefaultFs)) end md = AutoinstStorage.AddFilesysData(md, md) Ops.set(md, "type", :sw_raid) if Builtins.haskey(md, "raid_options") md = Builtins.remove(md, "raid_options") end Ops.set( md, "devices", Ops.get( AutoinstStorage.raid2device, Ops.get_string(md, "device", ""), [] ) ) Builtins.union(md, ) end allraid = [] if Ops.greater_than( Builtins.size( Ops.get_list(@ExistingRAID, ["/dev/md", "partitions"], []) ), 0 ) allraid = Builtins.union( Ops.get_list(@ExistingRAID, ["/dev/md", "partitions"], []), _RaidList ) else allraid = deep_copy(_RaidList) end Builtins.y2milestone("All RAID: %1", allraid) _RaidMap = { "partitions" => allraid, "type" => :CT_MD } Builtins.y2milestone("RaidMap: %1", _RaidMap) tg = Storage.GetTargetMap Ops.set(tg, "/dev/md", _RaidMap) Storage.SetTargetMap(tg) Builtins.y2milestone("Targets: %1", Storage.GetTargetMap) true end |