Module: Yast::PartitioningEpRaidLibInclude
- Defined in:
- ../../src/include/partitioning/ep-raid-lib.rb
Instance Method Summary (collapse)
- - (Object) AddDevices(raid_dev, devs)
- - (Object) CanModifyRaid(data)
- - (Object) EpCreateRaid
- - (Object) EpDeleteRaid(device)
- - (Object) EpEditRaid(device)
- - (Object) EpResizeRaid(device)
- - (Object) initialize_partitioning_ep_raid_lib(include_target)
- - (Object) RemoveDevices(raid_dev, devs)
- - (Object) ReplaceDevices(raid_dev, devs)
Instance Method Details
- (Object) AddDevices(raid_dev, devs)
32 33 34 35 36 37 38 39 40 41 42 43 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 32 def AddDevices(raid_dev, devs) devs = deep_copy(devs) ret = true Builtins.foreach(devs) do |dev| Storage.SetPartitionId(dev, Partitions.fsid_raid) Storage.SetPartitionFormat(dev, false, :none) end ret = false if !Storage.ExtendMd(raid_dev, devs) ret end |
- (Object) CanModifyRaid(data)
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 71 def CanModifyRaid(data) data = deep_copy(data) ret = true if Ops.get_boolean(data, "raid_inactive", false) txt = Builtins.sformat( _( "\n" + "Raid %1 cannot be modified because it is in inactive state.\n" + "This normally means the subset of raid devices is too small\n" + "for the raid to be usable.\n" ), Ops.get_string(data, "device", "") ) Popup.Error(txt) ret = false end ret end |
- (Object) EpCreateRaid
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 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 90 def EpCreateRaid target_map = Storage.GetTargetMap unused_devices = Builtins.filter(get_possible_rds(target_map)) do |dev| !Storage.IsUsedBy(dev) end if Ops.less_than(Builtins.size(unused_devices), 2) # error popup Popup.Error( _("There are not enough suitable unused devices to create a RAID.") ) return end data = { "new" => true, "type" => :sw_raid, "create" => true } r = Storage.NextMd Ops.set(data, "device", Ops.get_string(r, "device", "")) Ops.set(data, "nr", Ops.get_integer(r, "nr", 0)) if ( data_ref = arg_ref(data); _DlgCreateRaidNew_result = DlgCreateRaidNew(data_ref); data = data_ref.value; _DlgCreateRaidNew_result ) dev = data.fetch("device","") raid_type = Builtins.tosymbol(data.fetch("raid_type","raid0")) if Storage.CreateMdWithDevs(dev, raid_type, []) devices = Ops.get_list(data, "devices", []) AddDevices(dev, devices) chunk_size_k = Ops.get_integer(data, "chunk_size_k", 4) Storage.ChangeMdChunk(dev, chunk_size_k) if Builtins.haskey(data, "parity_algorithm") parity_algorithm = Ops.get_symbol( data, "parity_algorithm", :par_default ) if( parity_algorithm!=:par_default ) Storage.ChangeMdParitySymbol(dev, parity_algorithm) end end Storage.ChangeVolumeProperties(data) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create UpdateTableFocus(Ops.get_string(data, "device", "error")) end end nil end |
- (Object) EpDeleteRaid(device)
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 252 def EpDeleteRaid(device) if device == nil # error popup Popup.Error(_("No RAID selected.")) return end if EpDeleteDevice(device) new_focus = nil new_focus = :md if UI.QueryWidget(:tree, :CurrentItem) == device UpdateMainStatus() UpdateNavigationTree(new_focus) TreePanel.Create end nil end |
- (Object) EpEditRaid(device)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 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 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 150 def EpEditRaid(device) if device == nil # error popup Popup.Error(_("No RAID selected.")) return end target_map = Storage.GetTargetMap data = Storage.GetPartition(target_map, device) return if !CanModifyRaid(data) if Storage.IsUsedBy(data) # error popup, %1 is replaced by device name e.g. /dev/md1 Popup.Error( Builtins.sformat( _( "The RAID %1 is in use. It cannot be\nedited. To edit %1, make sure it is not used." ), device ) ) return end if ( data_ref = arg_ref(data); _DlgEditRaid_result = DlgEditRaid(data_ref); data = data_ref.value; _DlgEditRaid_result ) Storage.ChangeVolumeProperties(data) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create UpdateTableFocus(device) end nil end |
- (Object) EpResizeRaid(device)
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 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 193 def EpResizeRaid(device) if device == nil # error popup Popup.Error(_("No RAID selected.")) return end target_map = Storage.GetTargetMap data = Storage.GetPartition(target_map, device) return if !CanModifyRaid(data) if !Ops.get_boolean(data, "create", false) # error popup, %1 is replaced by device name e.g. /dev/md1 Popup.Error( Builtins.sformat( _( "The RAID %1 is already created on disk. It cannot be\nresized. To resize %1, remove it and create it again." ), device ) ) return end if Storage.IsUsedBy(data) # error popup, %1 is replaced by device name e.g. /dev/md1 Popup.Error( Builtins.sformat( _( "The RAID %1 is in use. It cannot be\nresized. To resize %1, make sure it is not used." ), device ) ) return end if ( data_ref = arg_ref(data); _DlgResizeRaid_result = DlgResizeRaid(data_ref); data = data_ref.value; _DlgResizeRaid_result ) dev = data.fetch("device","") devices_new = Ops.get_list(data, "devices_new", []) Builtins.y2milestone("devices_new:%1", devices_new) if Ops.greater_than(Builtins.size(devices_new), 0) ReplaceDevices(dev, devices_new) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create end end nil end |
- (Object) initialize_partitioning_ep_raid_lib(include_target)
28 29 30 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 28 def initialize_partitioning_ep_raid_lib(include_target) textdomain "storage" end |
- (Object) RemoveDevices(raid_dev, devs)
46 47 48 49 50 51 52 53 54 55 56 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 46 def RemoveDevices(raid_dev, devs) devs = deep_copy(devs) ret = true Builtins.foreach(devs) do |dev| Storage.UnchangePartitionId(dev) ret = false if !Storage.ShrinkMd(raid_dev, [dev]) end ret end |
- (Object) ReplaceDevices(raid_dev, devs)
58 59 60 61 62 63 64 65 66 67 68 69 |
# File '../../src/include/partitioning/ep-raid-lib.rb', line 58 def ReplaceDevices(raid_dev, devs) devs = deep_copy(devs) ret = true Builtins.foreach(devs) do |dev| Storage.SetPartitionId(dev, Partitions.fsid_raid) Storage.SetPartitionFormat(dev, false, :none) end ret = false if !Storage.ReplaceMd(raid_dev, devs) ret end |