Module: Yast::PartitioningEpLvmLibInclude
- Defined in:
- ../../src/include/partitioning/ep-lvm-lib.rb
Instance Method Summary (collapse)
- - (Object) AddPvs(vg_name, devs)
- - (Object) EpCreateLogicalVolume(device)
- - (Object) EpCreateVolumeGroup
- - (Object) EpDeleteLogicalVolume(device, context)
- - (Object) EpDeleteVolumeGroup(device)
- - (Object) EpEditLogicalVolume(device)
- - (Object) EpResizeLogicalVolume(device)
- - (Object) EpResizeVolumeGroup(device)
- - (Object) initialize_partitioning_ep_lvm_lib(include_target)
- - (Object) RemovePvs(vg_name, devs)
Instance Method Details
- (Object) AddPvs(vg_name, devs)
32 33 34 35 36 37 38 39 40 41 42 43 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 32 def AddPvs(vg_name, devs) devs = deep_copy(devs) ret = true Builtins.foreach(devs) do |dev| Storage.SetPartitionId(dev, Partitions.fsid_lvm) Storage.SetPartitionFormat(dev, false, :none) ret = false if !Storage.ExtendLvmVg(vg_name, dev) end ret end |
- (Object) EpCreateLogicalVolume(device)
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 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 211 def EpCreateLogicalVolume(device) if device == nil # error popup Popup.Error(_("No logical volume selected.")) return end target_map = Storage.GetTargetMap data = { "new" => true, "type" => :lvm, "create" => true } vg_name = Builtins.substring(device, 5) pools = Builtins.filter( Ops.get_list(target_map, [device, "partitions"], []) ) { |p| Ops.get_boolean(p, "pool", false) } if Ops.get_integer(target_map, [device, "pe_free"], 0) == 0 && Builtins.size(pools) == 0 # error popup Popup.Error( Builtins.sformat( _("No free space left in the volume group \"%1\"."), vg_name ) ) return end Ops.set(data, "vg_name", vg_name) Ops.set( data, "pesize", Ops.get_integer(target_map, [device, "pesize"], 0) ) maxs = Ops.divide( Ops.multiply( Ops.get_integer(target_map, [device, "pe_free"], 0), Ops.get_integer(target_map, [device, "pesize"], 0) ), 1024 ) Builtins.foreach(Ops.get_list(target_map, [device, "partitions"], [])) do |p| if Ops.get_boolean(p, "create", false) && Ops.get_boolean(p, "pool", false) maxs = Ops.subtract( maxs, ComputePoolMetadataSize( Ops.get_integer(p, "size_k", 0), Ops.get_integer(target_map, [device, "pesize"], 1024) ) ) end end Ops.set(data, "max_size_k", maxs) Ops.set( data, "max_stripes", Builtins.size( MergeDevices( Convert.convert( Ops.get(target_map, device, {}), :from => "map", :to => "map <string, any>" ) ) ) ) Ops.set(data, "using_devices", [device]) _Commit = lambda do |data| return addLogicalVolume(data, Builtins.substring(device, 5)) ? :finish : :back end if ( data_ref = arg_ref(data); _DlgCreateLogicalVolume_result = DlgCreateLogicalVolume( data_ref, fun_ref(_Commit, "symbol (map)") ); data = data_ref.value; _DlgCreateLogicalVolume_result ) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create UpdateTableFocus( Ops.add( Ops.add( Ops.add("/dev/", Ops.get_string(data, "vg_name", "error")), "/" ), Ops.get_string(data, "name", "error") ) ) end nil end |
- (Object) EpCreateVolumeGroup
59 60 61 62 63 64 65 66 67 68 69 70 71 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 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 59 def EpCreateVolumeGroup target_map = Storage.GetTargetMap unused_pvs = Builtins.filter(get_possible_pvs(target_map)) do |pv| !Storage.IsUsedBy(pv) end if Ops.less_than(Builtins.size(unused_pvs), 1) # error popup Popup.Error( _( "There are not enough suitable unused devices to create a volume group.\n" + "\n" + "To use LVM, at least one unused partition of type 0x8e (or 0x83) or one unused\n" + "RAID device is required. Change your partition table accordingly." ) ) return end data = {} if ( data_ref = arg_ref(data); _DlgCreateVolumeGroupNew_result = DlgCreateVolumeGroupNew(data_ref); data = data_ref.value; _DlgCreateVolumeGroupNew_result ) vg_name = Ops.get_string(data, "name", "error") pe_size = Ops.get_integer(data, "pesize", 0) if Storage.CreateLvmVgWithDevs(vg_name, pe_size, true, []) devices = Ops.get_list(data, "devices", []) AddPvs(vg_name, devices) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create UpdateTableFocus(Ops.add("/dev/", vg_name)) end end nil end |
- (Object) EpDeleteLogicalVolume(device, context)
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 399 def EpDeleteLogicalVolume(device, context) if device == nil # error popup Popup.Error(_("No logical volume selected.")) return end parent = ParentDevice(device) _next = NextDeviceAfterDelete(device) if EpDeleteDevice(device) UpdateMainStatus() case context when :table UpdateNavigationTree(nil) TreePanel.Create if !Builtins.isempty(_next) UI.ChangeWidget(Id(:table), :CurrentItem, _next) end when :overview UpdateNavigationTree(parent) TreePanel.Create end end nil end |
- (Object) EpDeleteVolumeGroup(device)
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 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 162 def EpDeleteVolumeGroup(device) if device == nil # error popup Popup.Error(_("No volume group selected.")) return false end vgname = Builtins.substring(device, 5) #LV device names log_volumes = Storage.GetAffectedDevices(device) #how many of those we have? count = Builtins.size(log_volumes) ret = false proceed = Ops.greater_than(count, 0) ? #non-empty VG - make sure user wants to delete all LVs ConfirmVgDelete(vgname, log_volumes) : #empty VG - simple Popup.YesNo( Builtins.sformat(_("Really delete the volume group \"%1\"?"), vgname) ) if proceed recursive = Storage.GetRecursiveRemoval Storage.SetRecursiveRemoval(true) if Storage.DeleteLvmVg(vgname) new_focus = nil new_focus = :lvm if UI.QueryWidget(:tree, :CurrentItem) == device UpdateMainStatus() UpdateNavigationTree(new_focus) TreePanel.Create ret = true else Popup.Error( Builtins.sformat(_("Deleting volume group \"%1\" failed."), vgname) ) #FIXME: some rollback? ret = false end Storage.SetRecursiveRemoval(recursive) end ret end |
- (Object) EpEditLogicalVolume(device)
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 312 def EpEditLogicalVolume(device) if device == nil # error popup Popup.Error(_("No logical volume selected.")) return end target_map = Storage.GetTargetMap data = Storage.GetPartition(target_map, device) if Ops.get_boolean(data, "pool", false) # error popup, %1 is replace by partition device name e.g. /dev/system/root Popup.Error( Builtins.sformat( _("The volume %1 is a thin pool.\nIt cannot be edited."), device ) ) return end if Storage.IsUsedBy(data) # error popup, %1 is replace by partition device name e.g. /dev/system/root Popup.Error( Builtins.sformat( _( "The volume %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); _DlgEditLogicalVolume_result = DlgEditLogicalVolume(data_ref); data = data_ref.value; _DlgEditLogicalVolume_result ) Storage.ChangeVolumeProperties(data) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create UpdateTableFocus(device) end nil end |
- (Object) EpResizeLogicalVolume(device)
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 364 def EpResizeLogicalVolume(device) if device == nil # error popup Popup.Error(_("No logical volume selected.")) return end target_map = Storage.GetTargetMap lv_data = Storage.GetPartition(target_map, device) vg_data = Storage.GetDisk(target_map, device) if ( lv_data_ref = arg_ref(lv_data); _DlgResizeLogicalVolumeNew_result = DlgResizeLogicalVolumeNew( lv_data_ref, vg_data ); lv_data = lv_data_ref.value; _DlgResizeLogicalVolumeNew_result ) Storage.ResizeVolume( device, Ops.get_string(vg_data, "device", "error"), Ops.get_integer(lv_data, "size_k", 0) ) UpdateMainStatus() TreePanel.Create UpdateTableFocus(device) end nil end |
- (Object) EpResizeVolumeGroup(device)
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 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 104 def EpResizeVolumeGroup(device) if device == nil # error popup Popup.Error(_("No volume group selected.")) return end target_map = Storage.GetTargetMap data = Convert.convert( Ops.get(target_map, device, {}), :from => "map", :to => "map <string, any>" ) vgname = Ops.get_string(data, "name", "error") _Commit = lambda do |data| devices_old = MergeDevices(data) devices_new = Ops.get_list(data, "devices_new", []) devices_added = AddedToList(devices_old, devices_new) devices_removed = RemovedFromList(devices_old, devices_new) if Ops.greater_than(Builtins.size(devices_added), 0) || Ops.greater_than(Builtins.size(devices_removed), 0) AddPvs(vgname, devices_added) if !RemovePvs(vgname, devices_removed) # error popup Popup.Error(_("Failed to remove some physical devices.")) # TODO: update data return :back end end :finish end if ( data_ref = arg_ref(data); _DlgResizeVolumeGroup_result = DlgResizeVolumeGroup( data_ref, fun_ref(_Commit, "symbol (map)") ); data = data_ref.value; _DlgResizeVolumeGroup_result ) UpdateMainStatus() UpdateNavigationTree(nil) TreePanel.Create end nil end |
- (Object) initialize_partitioning_ep_lvm_lib(include_target)
28 29 30 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 28 def initialize_partitioning_ep_lvm_lib(include_target) textdomain "storage" end |
- (Object) RemovePvs(vg_name, devs)
46 47 48 49 50 51 52 53 54 55 56 |
# File '../../src/include/partitioning/ep-lvm-lib.rb', line 46 def RemovePvs(vg_name, devs) devs = deep_copy(devs) ret = true Builtins.foreach(devs) do |dev| Storage.UnchangePartitionId(dev) ret = false if !Storage.ReduceLvmVg(vg_name, dev) end ret end |