Author: aschnell Date: Tue Feb 21 18:56:56 2012 New Revision: 67497 URL: http://svn.opensuse.org/viewcvs/yast?rev=67497&view=rev Log: - added functions to format channel, wwpn and fcp-lun Modified: trunk/s390/src/dasd/dialogs.ycp trunk/s390/src/modules/DASDController.ycp trunk/s390/src/modules/ZFCPController.ycp trunk/s390/src/zfcp/dialogs.ycp Modified: trunk/s390/src/dasd/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/dasd/dialogs.ycp?rev=67497&r1=67496&r2=67497&view=diff ============================================================================== --- trunk/s390/src/dasd/dialogs.ycp (original) +++ trunk/s390/src/dasd/dialogs.ycp Tue Feb 21 18:56:56 2012 @@ -185,10 +185,8 @@ `Table(`id(`table), `opt(`multiSelection), header, []), Mode::config () ? `HBox ( - // push button - `PushButton (`id (`add), _("A&dd New Disk")), - // push button - `PushButton (`id (`delete), _("De&lete Disk")), + `PushButton(`id(`add), Label::AddButton()), + `PushButton(`id(`delete), Label::DeleteButton()), `HStretch () ) : `HBox ( @@ -241,7 +239,7 @@ string filter_min = (string) UI::QueryWidget(`min_chan, `Value); string filter_max = (string) UI::QueryWidget(`max_chan, `Value); - if (!DASDController::ValidChannel(filter_min) || !DASDController::ValidChannel(filter_max)) + if (!DASDController::IsValidChannel(filter_min) || !DASDController::IsValidChannel(filter_max)) { // error popup Popup::Error(_("Invalid filter channels.")); @@ -249,8 +247,8 @@ continue; } - DASDController::filter_min = filter_min; - DASDController::filter_max = filter_max; + DASDController::filter_min = DASDController::FormatChannel(filter_min); + DASDController::filter_max = DASDController::FormatChannel(filter_max); ReloadDASDDialog (); ret = nil; @@ -508,7 +506,7 @@ { string channel = (string) UI::QueryWidget(`id(`channel), `Value); - if (!DASDController::ValidChannel(channel)) + if (!DASDController::IsValidChannel(channel)) { // error popup Popup::Error(_("Not a valid channel.")); @@ -517,6 +515,8 @@ continue; } + channel = DASDController::FormatChannel(channel); + if (DASDController::GetDeviceIndex(channel) != nil) { // error popup @@ -534,6 +534,8 @@ boolean format = (boolean) UI::QueryWidget(`id(`format), `Value); boolean diag = (boolean) UI::QueryWidget(`id(`diag), `Value); + channel = DASDController::FormatChannel(channel); + map<string, any> d = $[ "channel" : channel, "format" : format, Modified: trunk/s390/src/modules/DASDController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/DASDController.ycp?rev=67497&r1=67496&r2=67497&view=diff ============================================================================== --- trunk/s390/src/modules/DASDController.ycp (original) +++ trunk/s390/src/modules/DASDController.ycp Tue Feb 21 18:56:56 2012 @@ -107,11 +107,21 @@ } - global boolean ValidChannel(string channel) + global boolean IsValidChannel(string channel) { - string regexp = "^([0-9a-fA-F]{1}).([0-9a-fA-F]{1}).([0-9a-fA-F]{4})$"; + string regexp = "^([0-9a-fA-F]{1}).([0-9a-fA-F]{1}).([0-9a-fA-F]{1,4})$"; return regexpmatch(channel, regexp); } + + global string FormatChannel(string channel) + { + if (!IsValidChannel(channel)) + return channel; + + list<string> strs = splitstring(channel, "."); + strs[2] = String::PadZeros(strs[2]:"", 4); + return mergestring(strs, "."); + } /** @@ -202,6 +212,8 @@ devices = listmap (map<string, any> d, settings["devices"]:[], { index = index + 1; + d["channel"] = FormatChannel(d["channel"]:""); + d = filter(string k, any v, d, { return contains([ "channel", "format", "diag" ], k); }); Modified: trunk/s390/src/modules/ZFCPController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/ZFCPController.ycp?rev=67497&r1=67496&r2=67497&view=diff ============================================================================== --- trunk/s390/src/modules/ZFCPController.ycp (original) +++ trunk/s390/src/modules/ZFCPController.ycp Tue Feb 21 18:56:56 2012 @@ -16,6 +16,7 @@ import "Mode"; import "Report"; import "Popup"; + import "String"; global map<integer,map<string,any> > devices = $[]; @@ -116,24 +117,50 @@ } - global boolean ValidChannel(string channel) + global boolean IsValidChannel(string channel) { - string regexp = "^([0-9a-fA-F]{1}).([0-9a-fA-F]{1}).([0-9a-fA-F]{4})$"; + string regexp = "^([0-9a-fA-F]{1}).([0-9a-fA-F]{1}).([0-9a-fA-F]{1,4})$"; return regexpmatch(channel, regexp); } - global boolean ValidWWPN(string wwpn) + global string FormatChannel(string channel) { - string regexp = "^0x([0-9a-fA-F]{16})$"; + if (!IsValidChannel(channel)) + return channel; + + list<string> strs = splitstring(channel, "."); + strs[2] = String::PadZeros(strs[2]:"", 4); + return mergestring(strs, "."); + } + + global boolean IsValidWWPN(string wwpn) + { + string regexp = "^0x([0-9a-fA-F]{1,16})$"; return regexpmatch(wwpn, regexp); } - global boolean ValidFCPLUN(string fcp_lun) + global string FormatWWPN(string wwpn) + { + if (!IsValidWWPN(wwpn)) + return wwpn; + + return tohexstring(tointeger(wwpn), 16); + } + + global boolean IsValidFCPLUN(string fcp_lun) { - string regexp = "^0x([0-9a-fA-F]{16})$"; + string regexp = "^0x([0-9a-fA-F]{1,16})$"; return regexpmatch(fcp_lun, regexp); } + global string FormatFCPLUN(string fcp_lun) + { + if (!IsValidFCPLUN(fcp_lun)) + return fcp_lun; + + return tohexstring(tointeger(fcp_lun), 16); + } + global string GetNextLUN(string fcp_lun) { @@ -219,9 +246,9 @@ index = index + 1; map<string, any> m = $[ "detail" : $[ - "controller_id" : d["controller_id"]:"", - "wwpn" : d["wwpn"]:"", - "fcp_lun" : d["fcp_lun"]:"", + "controller_id" : FormatChannel(d["controller_id"]:""), + "wwpn" : FormatWWPN(d["wwpn"]:""), + "fcp_lun" : FormatFCPLUN(d["fcp_lun"]:""), ], ]; return $[ index : m ]; Modified: trunk/s390/src/zfcp/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/zfcp/dialogs.ycp?rev=67497&r1=67496&r2=67497&view=diff ============================================================================== --- trunk/s390/src/zfcp/dialogs.ycp (original) +++ trunk/s390/src/zfcp/dialogs.ycp Tue Feb 21 18:56:56 2012 @@ -168,7 +168,7 @@ string filter_min = (string) UI::QueryWidget(`min_chan, `Value); string filter_max = (string) UI::QueryWidget(`max_chan, `Value); - if (!ZFCPController::ValidChannel(filter_min) || !ZFCPController::ValidChannel(filter_max)) + if (!ZFCPController::IsValidChannel(filter_min) || !ZFCPController::IsValidChannel(filter_max)) { // error popup Popup::Error(_("Invalid filter channels.")); @@ -176,8 +176,8 @@ continue; } - ZFCPController::filter_min = filter_min; - ZFCPController::filter_max = filter_max; + ZFCPController::filter_min = ZFCPController::FormatChannel(filter_min); + ZFCPController::filter_max = ZFCPController::FormatChannel(filter_max); ReloadZFCPDialog(); ret = nil; @@ -297,7 +297,7 @@ string wwpn = (string) UI::QueryWidget(`id(`wwpn), `Value); string fcp_lun = (string) UI::QueryWidget(`id(`fcp_lun), `Value); - if (!ZFCPController::ValidChannel(channel)) + if (!ZFCPController::IsValidChannel(channel)) { // error popup Popup::Error(_("Not a valid channel.")); @@ -306,7 +306,7 @@ continue; } - if (!ZFCPController::ValidWWPN(wwpn)) + if (!ZFCPController::IsValidWWPN(wwpn)) { // error popup Report::Error(_("The entered WWPN is invalid.")); @@ -315,7 +315,7 @@ continue; } - if (!ZFCPController::ValidFCPLUN(fcp_lun)) + if (!ZFCPController::IsValidFCPLUN(fcp_lun)) { // error popup Report::Error(_("The entered FCP-LUN is invalid.")); @@ -332,6 +332,10 @@ string wwpn = (string) UI::QueryWidget(`id(`wwpn), `Value); string lun = (string) UI::QueryWidget(`id(`fcp_lun), `Value); + channel = ZFCPController::FormatChannel(channel); + wwpn = ZFCPController::FormatWWPN(wwpn); + lun = ZFCPController::FormatFCPLUN(lun); + ZFCPController::previous_settings["channel"] = channel; ZFCPController::previous_settings["wwpn"] = wwpn; ZFCPController::previous_settings["fcp_lun"] = lun; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org