[yast-commit] r48530 - in /branches/tmp/aschnell/part-redesign/storage/src/include: ep-lvm-dialogs.ycp ep-lvm-lib.ycp ep-raid-dialogs.ycp ep-raid-lib.ycp
Author: aschnell Date: Wed Jun 25 14:46:12 2008 New Revision: 48530 URL: http://svn.opensuse.org/viewcvs/yast?rev=48530&view=rev Log: - added some raid and lvm checks Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-lib.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/ep-raid-lib.ycp Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp?rev=48530&r1=48529&r2=48530&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp Wed Jun 25 14:46:12 2008 @@ -8,6 +8,20 @@ textdomain "storage"; + boolean CheckNumberOfDevicesForVg(integer num) + { + if (num < 1) + { + Error(sformat(_("Select at least one device."))); + return false; + } + else + { + return true; + } + } + + symbol MiniWorkflowStepVg(map<string, any> &data) { y2milestone("MiniWorkflowStepVg data:%1", data); @@ -21,7 +35,7 @@ map<string, map> target_map = Storage::GetTargetMap(); - list<map> free_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); + list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); term contents = `VBox(); @@ -33,7 +47,7 @@ contents = add(contents, `Left(`InputField(`id("vgname"), "Volume Group Name"))); contents = add(contents, `Left(`ComboBoxSelected(`id("pesize"), `opt(`editable), _("&Physical Extent Size"), pesizes_list, `id(pesize)))); - contents = add(contents, DevicesSelectionBox::Create(free_pvs, [], fields, + contents = add(contents, DevicesSelectionBox::Create(unused_pvs, [], fields, _("Available Physical Volumes:"), _("Selected Physical Volumes:"))); @@ -76,6 +90,9 @@ ")); widget = `again; } + + if (!CheckNumberOfDevicesForVg(size(pvs))) + widget = `again; } break; } @@ -109,13 +126,13 @@ map<string, map> target_map = Storage::GetTargetMap(); - list<map> free_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); + list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); list<map> used_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == vgname; }); term contents = `VBox(); - contents = add(contents, DevicesSelectionBox::Create(free_pvs, used_pvs, fields, + contents = add(contents, DevicesSelectionBox::Create(unused_pvs, used_pvs, fields, _("Available Physical Volumes:"), _("Selected Physical Volumes:"))); Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-lib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-lib.ycp?rev=48530&r1=48529&r2=48530&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-lib.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-lib.ycp Wed Jun 25 14:46:12 2008 @@ -10,6 +10,15 @@ void EpCreateVolumeGroup() { + map<string, map> target_map = Storage::GetTargetMap(); + list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); + + if (size(unused_pvs) < 1) + { + Error(_("There are not enough suitable unused devices to create a volume group.")); + return; + } + DlgCreateVolumeGroupNew(); } 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/storage/src/include/ep-raid-dialogs.ycp?rev=48530&r1=48529&r2=48530&view=diff ============================================================================== --- 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 14:46:12 2008 @@ -8,6 +8,33 @@ textdomain "storage"; + integer MinimalNumberOfDevicesForRaid(symbol raid_type) + { + map<symbol, 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) + { + 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" ]; + 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; + } + else + { + return true; + } + } + + symbol MiniWorkflowStepRaidTypeDevices(map<string, any> &data) { y2milestone("MiniWorkflowStepRaidTypeDevices data:%1", data); @@ -21,7 +48,7 @@ map<string, map> target_map = Storage::GetTargetMap(); - list<map> free_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == "" && + list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == "" && !contains(devices, dev["device"]:""); }); list<map> used_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == "" && contains(devices, dev["device"]:""); }); @@ -47,7 +74,7 @@ ))) ); - contents = add(contents, DevicesSelectionBox::Create(free_devices, used_devices, fields, + contents = add(contents, DevicesSelectionBox::Create(unused_devices, used_devices, fields, _("Available Devices:"), _("Selected Devices:"))); @@ -73,7 +100,8 @@ return device["device"]:""; }); - // TODO: checks + if (!CheckNumberOfDevicesForRaid(raid_type, size(devices))) + widget = `again; } break; } @@ -155,7 +183,7 @@ y2milestone("MiniWorkflowStepResizeRaid data:%1", data); string device = data["device"]:"error"; - + symbol raid_type = data["raid_type"]:`unknown; list<string> devices = []; @@ -163,17 +191,17 @@ map<string, map> target_map = Storage::GetTargetMap(); - list<map> free_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == ""; }); + list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == ""; }); list<map> used_devices = filter(map dev, get_possible_rds(target_map), { return "/dev/" + dev["used_by"]:"" == device; }); term contents = `VBox(); - contents = add(contents, DevicesSelectionBox::Create(free_devices, used_devices, fields, + contents = add(contents, DevicesSelectionBox::Create(unused_devices, used_devices, fields, _("Available Devices:"), _("Selected Devices:"))); - MiniWorkflow::SetContents(Greasemonkey::Transform(contents), "help"); + MiniWorkflow::SetContents(Greasemonkey::Transform(contents), "TODO"); MiniWorkflow::SetLastStep(false); @@ -193,7 +221,8 @@ return device["device"]:""; }); - // TODO: checks + if (!CheckNumberOfDevicesForRaid(raid_type, size(devices))) + widget = `again; } break; } 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/storage/src/include/ep-raid-lib.ycp?rev=48530&r1=48529&r2=48530&view=diff ============================================================================== --- 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 14:46:12 2008 @@ -10,6 +10,15 @@ void EpCreateRaid() { + map<string, map> target_map = Storage::GetTargetMap(); + list<map> unused_devices = filter(map dev, get_possible_rds(target_map), { return dev["used_by"]:"" == ""; }); + + if (size(unused_devices) < 2) + { + Error(_("There are not enough suitable unused devices to create a RAID.")); + return; + } + DlgCreateRaidNew(); } -- 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