[yast-commit] r67431 - in /trunk/s390: package/yast2-s390.changes src/dasd/dialogs.ycp src/modules/DASDController.ycp
Author: aschnell Date: Wed Feb 15 11:46:23 2012 New Revision: 67431 URL: http://svn.opensuse.org/viewcvs/yast?rev=67431&view=rev Log: - make DASD module work for autoyast editor Modified: trunk/s390/package/yast2-s390.changes trunk/s390/src/dasd/dialogs.ycp trunk/s390/src/modules/DASDController.ycp Modified: trunk/s390/package/yast2-s390.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/package/yast2-s390.changes?rev=67431&r1=67430&r2=67431&view=diff ============================================================================== --- trunk/s390/package/yast2-s390.changes (original) +++ trunk/s390/package/yast2-s390.changes Wed Feb 15 11:46:23 2012 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Wed Feb 15 11:25:49 CET 2012 - aschnell@suse.de + +- make DASD module work for autoyast editor + +------------------------------------------------------------------- Fri Feb 10 14:59:45 CET 2012 - aschnell@suse.de - used multiselection table in main DASD dialog Modified: trunk/s390/src/dasd/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/dasd/dialogs.ycp?rev=67431&r1=67430&r2=67431&view=diff ============================================================================== --- trunk/s390/src/dasd/dialogs.ycp (original) +++ trunk/s390/src/dasd/dialogs.ycp Wed Feb 15 11:46:23 2012 @@ -72,7 +72,7 @@ if (Mode::config ()) { items = maplist (integer k, map<string,any> d, devices, { - string channel = d["channel_id"]:""; + string channel = d["channel"]:""; string diag = String::YesNo(d["diag"]:false); string format = String::YesNo(d["format"]:false); return `item(`id(k), channel, format, diag); @@ -217,8 +217,6 @@ DASDController::filter_min = (string) UI::QueryWidget(`min_chan, `Value); DASDController::filter_max = (string) UI::QueryWidget(`max_chan, `Value); - DASDController::ProbeDisks(); - list<term> items = GetDASDDiskItems(); list<integer> selected = (list<integer>) UI::QueryWidget(`id(`table), `SelectedItems); @@ -242,7 +240,8 @@ { ret = UI::UserInput(); - if (ret == `filter) { + if (ret == `filter) + { ReloadDASDDialog (); ret = nil; continue; @@ -269,6 +268,8 @@ DASDController::ActivateDisk(channel, diag); }); + DASDController::ProbeDisks(); + ReloadDASDDialog (); ret = nil; } @@ -289,6 +290,8 @@ DASDController::DeactivateDisk(channel, diag); }); + DASDController::ProbeDisks(); + ReloadDASDDialog (); ret = nil; } @@ -311,6 +314,8 @@ DASDController::ActivateDisk(channel, true); }); + DASDController::ProbeDisks(); + ReloadDASDDialog (); ret = nil; } @@ -333,6 +338,8 @@ DASDController::ActivateDisk(channel, false); }); + DASDController::ProbeDisks(); + ReloadDASDDialog (); ret = nil; } @@ -428,6 +435,7 @@ return DASDController::devices[id, "dev_name"]:""; }); DASDController::FormatDisks (devices, par, write_vl, true); + DASDController::ProbeDisks(); ReloadDASDDialog (); UI::SetFocus (`table); ret = nil; @@ -436,6 +444,7 @@ return (symbol)ret; } + /** * Run the dialog for adding DASDs * @return symbol from AddDASDDiskDialog @@ -489,19 +498,24 @@ { ret = nil; } + } + else if (ret == `next) + { + // TODO check for duplicate channel } } if (ret == `next) { - string channel = (string)UI::QueryWidget (`id (`channel), `Value); - boolean format = (boolean)UI::QueryWidget (`id (`format), `Value); - boolean diag = (boolean)UI::QueryWidget (`id (`diag), `Value); + string channel = (string) UI::QueryWidget(`id(`channel), `Value); + boolean format = (boolean) UI::QueryWidget(`id(`format), `Value); + boolean diag = (boolean) UI::QueryWidget(`id(`diag), `Value); map<string,any> m = $[ - "channel_id" : channel, + "channel" : channel, "format" : format, "diag" : diag, ]; + integer index = 0; while (haskey (DASDController::devices, index)) index = index + 1; Modified: trunk/s390/src/modules/DASDController.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/s390/src/modules/DASDController.ycp?rev=67431&r1=67430&r2=67431&view=diff ============================================================================== --- trunk/s390/src/modules/DASDController.ycp (original) +++ trunk/s390/src/modules/DASDController.ycp Wed Feb 15 11:46:23 2012 @@ -14,15 +14,13 @@ textdomain "s390"; import "Mode"; -import "Progress"; import "Report"; -import "Stage"; -import "Summary"; import "Arch"; import "FileUtils"; import "Popup"; import "String"; + global map<integer,map<string,any> > devices = $[]; global string filter_min = "0.0.0000"; @@ -49,7 +47,7 @@ /** * Data was modified? */ -global boolean modified = false; +global boolean modified = true; // TODO /** */ @@ -95,21 +93,64 @@ return true; } + + string GetDeviceName(string channel) + { + string cmd = sformat("ls '/sys/bus/ccw/devices/%1/block/' | tr -d '\n'", channel); + map<string, any> disk = (map<string, any>) SCR::Execute(.target.bash_output, cmd); + if (disk["exit"]:-1 == 0 && !isempty(disk["stdout"]:"")) + return sformat("/dev/%1", disk["stdout"]:""); + + return nil; + } + + /** * Read all controller settings * @return true on success */ -global boolean Read() { +global boolean Read() +{ + ProbeDisks(); + + devices = mapmap(integer index, map<string, any> d, devices, { + d["format"] = d["format"]:false; + d["diag"] = d["diag"]:false; + return $[ index : d ]; + }); + disk_configured = false; return true; - } + /** * Write all controller settings * @return true on success */ -global boolean Write() { +global boolean Write() +{ + list<string> to_format = []; + + foreach(integer index, map<string, any> device, devices, { + string channel = device["channel"]:""; + boolean format = device["format"]:false; + boolean do_diag = device["diag"]:false; + ActivateDisk(channel, do_diag); + + if (format) + { + string dev_name = GetDeviceName(channel); + if (dev_name != nil) + to_format = add(to_format, dev_name); + } + }); + + y2milestone ("Disks to format: %1", to_format); + + if (!isempty(to_format)) + FormatDisks(to_format, 8, true, true); + if (disk_configured && Mode::normal ()) { string command = "/sbin/mkinitrd && /sbin/zipl"; @@ -121,6 +162,7 @@ { y2milestone ("No new disk configured"); } + return true; } @@ -130,50 +172,19 @@ * @param settings The YCP structure to be imported. * @return boolean True on success */ -global boolean Import (map settings) { - if (Mode::config ()) - { +global boolean Import(map settings) +{ integer index = -1; - devices = listmap (map<string,any> d, settings["devices"]:[], { - index = index + 1; - return $[ index : d ]; - }); - } - else if (Stage::initial ()) - { - // activate all disks first - map<string,boolean> to_format = $[]; - foreach (map d, settings["devices"]:[], { - boolean format = d["format"]:false; - boolean do_diag = d["diag"]:false; - string channel = d["channel"]:""; - if (channel != "") - { - to_format[channel] = format; - ActivateDisk (channel, do_diag); - } - }); + devices = listmap (map<string, any> d, settings["devices"]:[], { + index = index + 1; - // now probe all disks to get the mapping between channel and device - ProbeDisks (); + d = filter(string k, any v, d, { + return contains([ "channel", "format", "diag" ], k); + }); - // now map the channels of the disks to format to devices - list<string> format_list = []; - foreach (integer i, map<string,any> d, devices, { - string channel = d["channel"]:""; - string device = d["dev_name"]:""; - if (channel != "" && device != "") - { - if (to_format[channel]:false) - format_list = add (format_list, device); - } + return $[ index : d ]; }); - y2milestone ("Disks to format: %1", format_list); - // now format the disks - if (size (format_list) > 0) - FormatDisks (format_list, 8, true, true); - } return true; } @@ -185,44 +196,16 @@ */ global map<string, list> Export() { - ProbeDisks(); - - if (Mode::config()) - { list<map<string, any> > l = maplist(integer i, map<string, any> d, devices, { - // if possible, use device by-path (bnc#591603) - string tmp = find(string s, d["dev_names"]:[], { - return String::StartsWith(s, "/dev/disk/by-path/"); - }); - if (tmp != nil) - d["dev_name"] = tmp; - return d; - }); - - l = filter(map<string, any> m, l, { - return m["resource", "io", 0, "active"]:false; - }); - /* - l = maplist(map<string, any> m, l, { - return filter(string k, any v, m, { - return contains([ "channel", "dev_name" ], k); + d = filter(string k, any v, d, { + return contains([ "channel", "format", "diag" ], k); }); - }); - */ - return $[ "devices" : l ]; - } - else - { - list<map<string, any> > l = maplist (integer i, map<string, any> d, devices, { - return $[ "channel" : d["channel"]:"", - "format" : false, - "diag" : false ]; - }); + return d; + }); return $[ "devices" : l ]; - } } @@ -276,25 +259,24 @@ global list<string> Summary() { list<string> ret = maplist (integer index, map<string,any> d, devices, { - string s = ""; // summary text, %1 is channel ID (number), // %2 and %3 are Yes or No - s = sformat (_("Channel ID: %1, Format: %2, Use DIAG: %3"), - d["channel"]:"", String::YesNo(d["format"]:false), String::YesNo(d["diag"]:false) - ); - return s; + return sformat(_("Channel: %1, Format: %2, Use DIAG: %3"), d["channel"]:"", + String::YesNo(d["format"]:false), String::YesNo(d["diag"]:false)); }); y2milestone ("Summary: %1", ret); return ret; } + /** * Return packages needed to be installed and removed during * Autoinstallation to insure module has all needed software * installed. * @return map with 2 lists. */ -global map AutoPackages() { +global map AutoPackages() +{ return $[ "install":[], "remove":[] ]; } @@ -320,18 +302,16 @@ */ global void ProbeDisks() { -/* if (Mode::config ()) - return; */ - // popup label UI::OpenDialog (`Label (_("Reading Configured DASD Disks"))); list<map<string, any> > disks = (list<map<string, any> >) SCR::Read(.probe.disk); disks = filter (map<string, any> d, disks, { return tolower(d["device"]:"") == "dasd"; }); - + disks = maplist (map<string,any> d, disks, { string channel = d["sysfs_bus_id"]:"0.0.0000"; d["channel"] = channel; + boolean active = d["resource", "io", 0, "active"]:false; if (active) { @@ -346,56 +326,29 @@ } d["formatted"] = formatted; d["partition_info"] = GetPartitionInfo (device); - } - string diag_file = sformat("/sys/%1/device/use_diag", d["sysfs_id"]:""); - if (FileUtils::Exists(diag_file)) - { - string use_diag = (string)SCR::Read(.target.string, diag_file); - diag[channel] = substring(use_diag, 0, 1) == "1"; + string diag_file = sformat("/sys/%1/device/use_diag", d["sysfs_id"]:""); + if (FileUtils::Exists(diag_file)) + { + string use_diag = (string) SCR::Read(.target.string, diag_file); + d["diag"] = substring(use_diag, 0, 1) == "1"; + diag[channel] = substring(use_diag, 0, 1) == "1"; + } } + d = filter(string k, any v, d, { return contains([ "channel", "diag", + "resource", "formatted", "partition_info", "dev_name", "detail", + "device_id", "sub_device_id" ], k); }); + return d; }); + integer index = -1; - DASDController::devices = listmap (map<string,any> d, disks, { + devices = listmap (map<string, any> d, disks, { index = index + 1; return $[ index : d ]; }); -/* -DASDController::devices = (map<integer,map<string,any> >) - SCR::Read (.target.ycp, "/root/dasddevices.ycp"); -$[ -0:$[ -"bus":"None", -"bus_hwcfg":"none", -"channel":"0.0.0150", -"class_id":262, -"detail":$["cu_model":233, "dev_model":10, "lcss":0], -"dev_name":"/dev/dasda", -"dev_names":["/dev/dasda"], -"dev_num":$["major":94, "minor":0, "range":4, "type":"b"], -"device":"DASD", -"device_id":276880, -"driver":"io_subchannel", -"drivers":[$["active":true, "modprobe":true, "modules":[["dasd_eckd_mod", ""]]]], -"formatted":true, -"model":"IBM DASD", -"old_unique_key":"N5EP.J4gQoPlOYuE", -"partition_info":"--", -"prog_if":1, -"resource":$["disk_log_geo":[$["cylinders":3339, "heads":15, "sectors":12]], "io":[$["active":true, "length":1, "mode":"rw", "start":336]], "size":[$["unit":"sectors", "x":601020, "y":4096]]], -"sub_class_id":0, -"sub_device_id":275344, -"sysfs_bus_id":"0.0.0150", -"unique_key":"kNlH.ALFATSt_U8F", -"vendor":"IBM", -"vendor_id":286721 -], -]; -*/ - UI::CloseDialog (); } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
aschnell@svn2.opensuse.org