[yast-commit] r48539 - in /branches/tmp/aschnell/part-redesign/storage/src/include: ep-raid-dialogs.ycp ep-raid-lib.ycp raid_lib.ycp

Author: aschnell Date: Wed Jun 25 23:36:15 2008 New Revision: 48539 URL: http://svn.opensuse.org/viewcvs/yast?rev=48539&view=rev Log: - work on resizing raids (I hate those maps) Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-lib.ycp branches/tmp/aschnell/part-redesign/storage/src/include/raid_lib.ycp Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-dialogs.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-dialogs.ycp Wed Jun 25 23:36:15 2008 @@ -8,22 +8,22 @@ textdomain "storage"; - integer MinimalNumberOfDevicesForRaid(symbol raid_type) + integer MinimalNumberOfDevicesForRaid(string raid_type) { - map<symbol, integer> info = $[ `raid0 : 2, `raid1 : 2, `raid5 : 3, `raid6 : 4, - `raid10 : 2, `multipath : 2 ]; + map<string, integer> info = $[ "raid0" : 2, "raid1" : 2, "raid5" : 3, "raid6" : 4, + "raid10" : 2, "multipath" : 2 ]; return info[raid_type]:0; } - boolean CheckNumberOfDevicesForRaid(symbol raid_type, integer num) + boolean CheckNumberOfDevicesForRaid(string raid_type, integer num) { integer min_num = MinimalNumberOfDevicesForRaid(raid_type); if (num < min_num) { - map<symbol, string> info = $[ `raid0 : "RAID0", `raid1 : "RAID1", `raid5 : "RAID5", `raid6 : "RAID6", - `raid10 : "RAID10", `multipath : "Multipath RAID" ]; + map<string, string> info = $[ "raid0" : "RAID0", "raid1" : "RAID1", "raid5" : "RAID5", "raid6" : "RAID6", + "raid10" : "RAID10", "multipath" : "Multipath RAID" ]; Error(sformat(_("For %1, select at least %2 device.", "For %1, select at least %2 devices.", min_num), info[raid_type]:"error", min_num)); return false; @@ -39,7 +39,7 @@ { y2milestone("MiniWorkflowStepRaidTypeDevices data:%1", data); - symbol raid_type = data["raid_type"]:`raid0; + string raid_type = data["raid_type"]:"raid0"; string device = data["device"]:"error"; list<string> devices = data["devices"]:[]; @@ -61,15 +61,15 @@ // Translators, 'Striping' is a technical term here. Translate only if // you are sure!! If in doubt, leave it in English. `LeftRadioButton(`id(`raid0), _("RAID &0 (Striping)"), - raid_type == `raid0), + raid_type == "raid0"), // Translators, 'Mirroring' is a technical term here. Translate only if // you are sure!! If in doubt, leave it in English. `LeftRadioButton(`id(`raid1), _("RAID &1 (Mirroring)"), - raid_type == `raid1), + raid_type == "raid1"), // Translators, 'Redundant Striping' is a technical term here. Translate // only if you are sure!! If in doubt, leave it in English. `LeftRadioButton(`id(`raid5), _("RAID &5 (Redundant Striping)"), - raid_type == `raid5) + raid_type == "raid5") ) )))) ); @@ -94,7 +94,7 @@ { case `next: { - raid_type = (symbol) UI::QueryWidget(`id(`raid_type), `Value); + raid_type = substring(tostring((symbol) UI::QueryWidget(`id(`raid_type), `Value)), 1); devices = maplist(map device, DevicesSelectionBox::GetSelectedDevices(), { return device["device"]:""; @@ -124,7 +124,7 @@ { y2milestone("MiniWorkflowStepRaidOptions data:%1", data); - symbol raid_type = data["raid_type"]:`raid0; + string raid_type = data["raid_type"]:"error"; integer chunk_size = (data["chunk_size_k"]:4)*1024; // TODO symbol parity_algorithm = data["parity_algorithm"]:`left_asymmetric; @@ -137,7 +137,7 @@ `id(chunk_size))) ); - if (raid_type == `raid5) + if (raid_type == "raid5") options = add(options, `Left(`ComboBoxSelected(`id(`parity_algorithm), `opt(`hstretch), _("Parity &Algorithm"), [ `item(`id(`left_asymmetric), "left-asymmetric"), @@ -183,8 +183,8 @@ y2milestone("MiniWorkflowStepResizeRaid data:%1", data); string device = data["device"]:"error"; - symbol raid_type = data["raid_type"]:`unknown; - list<string> devices = []; + string raid_type = data["raid_type"]:"error"; + list<string> devices_new = []; list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size ]); @@ -203,7 +203,7 @@ MiniWorkflow::SetContents(Greasemonkey::Transform(contents), "TODO"); - MiniWorkflow::SetLastStep(false); + MiniWorkflow::SetLastStep(true); symbol widget = nil; @@ -217,11 +217,11 @@ { case `next: { - devices = maplist(map device, DevicesSelectionBox::GetSelectedDevices(), { + devices_new = maplist(map device, DevicesSelectionBox::GetSelectedDevices(), { return device["device"]:""; }); - if (!CheckNumberOfDevicesForRaid(raid_type, size(devices))) + if (!CheckNumberOfDevicesForRaid(raid_type, size(devices_new))) widget = `again; } break; @@ -231,7 +231,9 @@ if (widget == `next) { - data["devices"] = devices; + data["devices_new"] = devices_new; + + widget = `finish; } y2milestone("MiniWorkflowStepResizeRaid data:%1 ret:%2", data, widget); @@ -276,10 +278,8 @@ } - boolean DlgResizeRaid(string device) + boolean DlgResizeRaid(map<string, any> data) { - map<string, any> data = $[ "device" : device ]; - map<string, any> aliases = $[ "TheOne" : ``(MiniWorkflowStepResizeRaid(data)) ]; @@ -288,14 +288,34 @@ "TheOne" : $[ `finish : `finish ] ]; - string title = sformat(_("Resize RAID %1"), device); + string title = sformat(_("Resize RAID %1"), data["device"]:"error"); symbol widget = MiniWorkflow::Run(title, raid_icon, aliases, sequence, "TheOne"); if (widget == `finish) { - if (true) // TODO + integer raid_nr = data["nr"]:0; + + list<string> devices_old = data["devices"]:[]; + list<string> devices_new = data["devices_new"]:[]; + + list<string> devices_added = filter(string dev, devices_new, { return !contains(devices_old, dev); }); + list<string> devices_removed = filter(string dev, devices_old, { return !contains(devices_new, dev); }); + + if (size(devices_added) > 0 || size(devices_removed) > 0) { + foreach(string dev, devices_removed, { + Storage::UnchangePartitionId(dev); + Storage::ShrinkMd(raid_nr, dev); + }); + + foreach(string dev, devices_added, { + Storage::SetPartitionId(dev, Partitions::fsid_raid); + Storage::ExtendMd(raid_nr, dev); + }); + + data["devices"] = devices_new; + UpdateNavigationTree(nil); TreePanel::Create(); } @@ -307,11 +327,11 @@ boolean DlgEditRaid(string device) { - map<string, any> data = $[ "flavour" : `raid ]; - map<string, map> target_map = Storage::GetTargetMap(); - data = Storage::GetPartition(target_map, device); + map<string, any> data = Storage::GetPartition(target_map, device); + data["format"] = false; + data["flavour"] = `raid; map<string, any> aliases = $[ "FormatMount" : ``(MiniWorkflowStepFormatMount(data)), Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-lib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-lib.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-lib.ycp Wed Jun 25 23:36:15 2008 @@ -36,16 +36,16 @@ void EpResizeRaid(string device) { map<string, map> target_map = Storage::GetTargetMap(); - map volume = Storage::GetPartition(target_map, device); + map<string, any> data = Storage::GetPartition(target_map, device); - if (!volume["create"]:false) + if (!data["create"]:false) { Error(sformat(_("The RAID %1 is already created on disk. It cannot be resized. To resize %1, remove it and create it again."), device)); return; } - DlgResizeRaid(device); + DlgResizeRaid(data); } Modified: branches/tmp/aschnell/part-redesign/storage/src/include/raid_lib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/sto... ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/raid_lib.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/raid_lib.ycp Wed Jun 25 23:36:15 2008 @@ -374,12 +374,20 @@ void addRaid(map<string, any> data) { - Storage::CreateMdWithDevs(data["nr"]:0, data["raid_type"]:`raid0, data["devices"]:[]); + integer nr = data["nr"]:0; + symbol raid_type = symbolof(toterm(data["raid_type"]:"raid0")); + list<string> devices = data["devices"]:[]; - Storage::ChangeMdChunk(data["nr"]:0, data["chunk_size_k"]:4); + Storage::CreateMdWithDevs(nr, raid_type, devices); - if (data["raid_type"]:`raid0 == `raid5) - Storage::ChangeMdParitySymbol(data["nr"]:0,data["parity_algorithm"]:`left_asymmetric ); + foreach(string dev, devices, { + Storage::SetPartitionId(dev, Partitions::fsid_raid); + }); + + Storage::ChangeMdChunk(nr, data["chunk_size_k"]:4); + + if (raid_type == `raid5) + Storage::ChangeMdParitySymbol(nr, data["parity_algorithm"]:`left_asymmetric ); Storage::ChangeVolumeProperties(data); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn.opensuse.org