File bug-295546_res-conf-deleted.pathch of Package yast2-drbd

diff -Nru yast2-drbd-2.13.1.ori/src/Drbd.ycp yast2-drbd-2.13.1/src/Drbd.ycp
--- yast2-drbd-2.13.1.ori/src/Drbd.ycp	2007-07-30 14:58:26.000000000 +0800
+++ yast2-drbd-2.13.1/src/Drbd.ycp	2007-07-30 16:58:45.000000000 +0800
@@ -193,6 +193,26 @@
 }
 
 
+map del_empty_item(map old_map)
+{
+    map new_map = old_map;
+    foreach (string key, any val, (map<string, any>) old_map,
+    {
+        if (is(val, map))
+        {
+            new_map[key] = del_empty_item((map)val);
+        } else //if (is(val, string))
+        {
+            if (size((string)val) == 0)
+                new_map[key] = nil;
+                //new_map = remove(new_map, key);
+        }
+    });
+
+    return new_map;
+}
+
+
 global boolean Write() {
 	/* DRBD write dialog caption */
 	string caption = _("Writing DRBD Configuration");
@@ -229,6 +249,7 @@
 
 	//resource config here
 	Progress::NextStage();
+	resource_config = del_empty_item(resource_config);
 	recursive_write_map(.drbd.resources, (map<string, any>)resource_config);
 	y2debug("to write resource config: resource_config=%1", resource_config);
 
diff -Nru yast2-drbd-2.13.1.ori/src/resource_conf.ycp yast2-drbd-2.13.1/src/resource_conf.ycp
--- yast2-drbd-2.13.1.ori/src/resource_conf.ycp	2007-07-30 14:58:26.000000000 +0800
+++ yast2-drbd-2.13.1/src/resource_conf.ycp	2007-07-31 00:08:51.000000000 +0800
@@ -157,6 +157,9 @@
 
 map<string, any> save_basic_config(map<string, any> res_config)
 {
+	if (UI::QueryWidget(`id(`resname), `Value) == nil)
+		return res_config;
+
 	res_config["resname"] = (string) UI::QueryWidget(`id(`resname), `Value);
 	res_config["on"] = $[
 		(string) UI::QueryWidget(`id(`n1_name), `Value) : $[
@@ -241,8 +244,18 @@
 
 map<string, any> save_advance_config(map<string, any> res_config)
 {
+	if (UI::QueryWidget(`id(`protocol), `Value) == nil)
+	{
+		if (res_config["protocol"]:nil == nil) res_config["protocol"] = "C";
+		if (res_config["incon-degr-cmd"]:nil == nil) res_config["incon-degr-cmd"] = "echo '!DRBD! pri on incon-degr' | wall ; sleep 60 ; halt -f";
+		if (res_config["disk", "on-io-error"]:nil == nil) res_config["disk"] = $["on-io-error" : "pass_on"];
+		if (res_config["net", "on-disconnect"]:nil == nil) res_config["net"] = $["on-disconnect" : "reconnect"];
+		return res_config;
+	}
+
+
 	res_config["protocol"] = (string) UI::QueryWidget(`id(`protocol), `Value);
-	res_config["cmd"] = (string) UI::QueryWidget(`id(`cmd), `Value);
+	res_config["incon-degr-cmd"] = (string) UI::QueryWidget(`id(`cmd), `Value);
 
 	res_config["startup"] = $[
 		"wfc-timeout" : (string) UI::QueryWidget(`id(`wfc_timeout), `Value),
@@ -267,14 +280,11 @@
 
 	res_config["syncer"] = $[
 		"al-extents" : (string) UI::QueryWidget(`id(`al_extents), `Value),
-		"group  "    : (string) UI::QueryWidget(`id(`group), `Value),
+		"group"      : (string) UI::QueryWidget(`id(`group), `Value),
 		"rate"       : (string) UI::QueryWidget(`id(`rate), `Value)
 	];
 
-	if (res_config["protocol"]:nil == nil) res_config["protocol"] = "C";
-	if (res_config["disk", "on-io-error"]:nil == nil) res_config["disk", "on-io-error"] = "pass_on";
-	if (res_config["net", "on-disconnect"]:nil == nil) res_config["net", "on-disconnect"] = "reconnect";
-
+		y2debug("ret = %1", res_config);
 	return res_config;
 }
 
@@ -287,11 +297,10 @@
 		if (is(val, map))
 		{
 			new_map[key] = del_empty_item((map)val);
-		} else //if (is(val, string))
+		} else
 		{
 			if (size((string)val) == 0)
 				new_map[key] = nil;
-				//new_map = remove(new_map, key);
 		}
 	});
 
@@ -303,7 +312,7 @@
 {
 	any ret = nil;
 	symbol cur_page = `basic;
-    map<string, any> res_config = Drbd::resource_config[resname]:$[];
+	map<string, any> res_config = Drbd::resource_config[resname]:$[];
 	res_config["resname"] = resname;
 
 	my_SetContents("resource_conf", res_basic_config_get_dialog(res_config));
@@ -313,7 +322,7 @@
 
 	while (true)
 	{
-        Wizard::SelectTreeItem("resource_conf");
+		Wizard::SelectTreeItem("resource_conf");
 		ret = UI::UserInput();
 
 		y2debug("in ResDialog(), UserInput ret=%1", ret);
@@ -334,8 +343,8 @@
 		}
 
 
-        if (ret == `advance || (ret == `ok && cur_page == `basic))
-        {
+		if (ret == `advance || (ret == `ok && cur_page == `basic))
+		{
 			if ((string)UI::QueryWidget(`id(`n1_name), `Value) == (string)UI::QueryWidget(`id(`n2_name), `Value))
 			{
 				Popup::Warning("Node names must be different.");
@@ -348,7 +357,7 @@
                 string str = (string) UI::QueryWidget(`id(the_id), `Value);
                 if (str == nil || size(str) == 0)
                 {
-                    Popup::Warning("Pleas fill all the items.");
+                    Popup::Warning("Pleas fill out all the items.");
 					ret = nil;
 					break;
                 }
@@ -362,6 +371,7 @@
 			cur_page = `advance;
 
 			res_config = save_basic_config(res_config);
+			y2debug("res_config = %1", res_config);
 
 			my_SetContents("resource_conf", res_advance_config_get_dialog(res_config));
 
@@ -398,8 +408,7 @@
 			res_config = save_basic_config(res_config);
 			res_config = save_advance_config(res_config);
 
-			res_config = (map<string, any>) del_empty_item(res_config);
-			y2debug("del_empty_item(res_config)=%1", res_config);
+			y2debug("res_config=%1", res_config);
 
 			if (size(resname) > 0)
 			{	//edit