[yast-commit] r48535 - in /branches/tmp/aschnell/part-redesign/storage/src/include: ep-lvm-dialogs.ycp lvm_lib.ycp
Author: aschnell Date: Wed Jun 25 16:50:07 2008 New Revision: 48535 URL: http://svn.opensuse.org/viewcvs/yast?rev=48535&view=rev Log: - check volume group name Modified: branches/tmp/aschnell/part-redesign/storage/src/include/ep-lvm-dialogs.ycp branches/tmp/aschnell/part-redesign/storage/src/include/lvm_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=48535&r1=48534&r2=48535&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 16:50:07 2008 @@ -8,6 +8,64 @@ textdomain "storage"; + boolean CheckVgName(string name) + { + if (size(name) == 0) + { + // error popup text + Error(_("Enter a name for the volume group.")); + return false; + } + + if (size(name) > 128) + { + // error popup text + Error(_("The name for the volume group is longer than 128 characters.")); + return false; + } + + if (substring(name, 0, 1) == "-") + { + // error popup text + Error(_("The name for the volume group must not start with a \"-\".")); + return false; + } + + string allowed_chars = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "abcdefghijklmnopqrstuvwxyz" + "._-+"; + if (findfirstnotof(name, allowed_chars) != nil) + { + // error popup text + Error(_("The name for the volume group contains illegal characters. Allowed +are alphanumeric characters, \".\", \"_\", \"-\" and \"+\".")); + return false; + } + + return true; + } + + + boolean CheckVgNameConflict(string name, list<string> vgs) + { + if (contains(vgs, name)) + { + // error popup text + Error(sformat(_("The volume group \"%1\" already exists."), name )); + return false; + } + + if (!check_vgname_dev(name)) + { + // error popup text + Error(sformat(_("The volume group name \"%1\" conflicts +with another entry in the /dev directory.\n"), name)); + return false; + } + + return true; + } + + boolean CheckPeSize(integer pe_size) { if (!Integer::IsPowerOfTwo(pe_size) || pe_size < 1024) @@ -41,7 +99,11 @@ { y2milestone("MiniWorkflowStepVg data:%1", data); - string vgname = ""; + map<string, map> target_map = Storage::GetTargetMap(); + + list<string> vgs = get_vgs(target_map); + + string vgname = size(vgs) == 0 ? "system" : ""; integer pesize = 4*1024*1024; list<string> pvs = []; @@ -49,7 +111,6 @@ list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size ]); - map<string, map> target_map = Storage::GetTargetMap(); list<map> unused_pvs = filter(map pv, get_possible_pvs(target_map), { return pv["used_by"]:"" == ""; }); @@ -94,10 +155,8 @@ return pv["device"]:""; }); - // TODO: checks - - if (!CheckPeSize(pesize) || - !CheckNumberOfDevicesForVg(size(pvs))) + if (!CheckVgName(vgname) || !CheckVgNameConflict(vgname, vgs) || + !CheckPeSize(pesize) || !CheckNumberOfDevicesForVg(size(pvs))) widget = `again; } break; Modified: branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp?rev=48535&r1=48534&r2=48535&view=diff ============================================================================== --- branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp (original) +++ branches/tmp/aschnell/part-redesign/storage/src/include/lvm_lib.ycp Wed Jun 25 16:50:07 2008 @@ -36,12 +36,11 @@ ////////////////////////////////////////////////////////////////////// // get a list of all volume groups in the targetMap -define list get_vgs( map<string,map> targetMap ) - ``{ - list lvm_vg = []; +list<string> get_vgs( map<string,map> targetMap ) +{ + list<string> lvm_vg = []; - foreach( string dev, map devmap, targetMap, - ``{ + foreach( string dev, map devmap, targetMap, { if ( devmap["type"]:`CT_UNKNOWN==`CT_LVM ) { // add a found volume group @@ -49,7 +48,7 @@ } }); return( lvm_vg ); - }; +}; ////////////////////////////////////////////////////////////////////// // pesize to byte -- 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