File use-storage-activatemultipath.diff of Package yast2-multipath

Index: yast2-multipath-2.17.1/src/complex.ycp
===================================================================
--- yast2-multipath-2.17.1.orig/src/complex.ycp	2008-09-27 14:18:03.000000000 +0800
+++ yast2-multipath-2.17.1/src/complex.ycp	2008-12-03 13:55:41.000000000 +0800
@@ -33,6 +33,7 @@
 textdomain "multipath";
 
 import "Service";
+import "Storage";
 
 integer service_status = 0;
 boolean has_dumbtab = false;
@@ -2659,8 +2660,12 @@
 
 
 void Update_Service_Status() {
-    integer ret = Service::Status("multipathd");
-//    integer ret = (integer) SCR::Execute(.target.bash, "/etc/init.d/multipathd status");
+	integer ret = 0;
+	if (Mode::normal() && Stage::normal()) {
+		ret = Service::Status("multipathd");
+	} else {
+		ret = (integer)SCR::Execute(.target.bash, "/bin/ps -A -o comm | grep -q multipathd");
+	}
     if (ret == 0) {
         UI::ChangeWidget(`id(`stop_multipath), `Value, false);
         UI::ChangeWidget(`id(`start_multipath), `Value, true);
@@ -2691,37 +2696,61 @@
     UI::ChangeWidget(`id(`status_summary_id), `Value, info);	
 }
 
+void CallInsserv( boolean on, string name )
+{
+	y2milestone( "CallInsserv on:%1 name:%2", on, name );
+	string scrname = "/etc/init.d/" + name;
+	if( SCR::Read( .target.size, scrname )>0 )
+	{
+		string cmd = "cd / && /sbin/insserv ";
+		if( !on )
+			cmd = cmd + "-r ";
+		cmd = cmd + scrname;
+		y2milestone( "CallInsserv cmd %1", cmd );
+		map bo = (map)SCR::Execute (.target.bash_output, cmd );
+		y2milestone( "CallInsserv bo %1", bo );
+	}
+}
+
 void Start_Service() {
     if (service_status == 1)
 	return;
     string prop_info = _("Use multipath failed:") + "\n";
 
-    boolean ret = Service::Enable("boot.multipath");
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not enable boot.multipath") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
-    ret = Service::Enable("multipathd");
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not enable multipathd") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
-    /* do not check result for starting boot.multipath */
-    ret = Service::Start("boot.multipath");
-    ret = Service::Start("multipathd"); 
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not start multipathd") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
+	if (Mode::normal() && Stage::normal()) {
+		boolean ret = Service::Enable("boot.multipath");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not enable boot.multipath") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+		ret = Service::Enable("multipathd");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not enable multipathd") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+		/* do not check result for starting boot.multipath */
+		ret = Service::Start("boot.multipath");
+		ret = Service::Start("multipathd");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not start multipathd") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+
+	} else {
+//		CallInsserv(true, "boot.multipath");
+//		CallInsserv(true, "multipathd");
+		Storage::ActivateMultipath(true);
+	}
+
     service_status = 1;
     Update_Service_Status();
 }
@@ -2731,32 +2760,40 @@
 	return;
     string prop_info = _("Do not use multipath failed:") + "\n";
 
-    boolean ret = Service::Stop("multipathd");
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not stop multipath") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
-    /* do not check result of stopping boot.multipath */
-    ret = Service::Stop("boot.multipath");
-    ret = Service::Disable("multipathd");
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not disable multipathd") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
-    ret = Service::Disable("boot.multipath");
-    if (ret == false)
-    {
-	prop_info = prop_info + _("* Can not disable boot.multipath") + "\n";
-	Popup::Message(prop_info);
-	Update_Service_Status();
-	return;
-    }
+	if (Mode::normal() && Stage::normal()) {
+		boolean ret = Service::Stop("multipathd");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not stop multipath") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+		/* do not check result of stopping boot.multipath */
+		ret = Service::Stop("boot.multipath");
+		ret = Service::Disable("multipathd");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not disable multipathd") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+		ret = Service::Disable("boot.multipath");
+		if (ret == false)
+		{
+			prop_info = prop_info + _("* Can not disable boot.multipath") + "\n";
+			Popup::Message(prop_info);
+			Update_Service_Status();
+			return;
+		}
+
+	} else {
+		Storage::ActivateMultipath(false);
+//		CallInsserv(false, "multipathd");
+//		CallInsserv(false, "boot.multipath");
+	}
+
     service_status = 0;
     Update_Service_Status();
 }
Index: yast2-multipath-2.17.1/src/Multipath.ycp
===================================================================
--- yast2-multipath-2.17.1.orig/src/Multipath.ycp	2008-12-03 13:55:41.000000000 +0800
+++ yast2-multipath-2.17.1/src/Multipath.ycp	2008-12-03 14:56:56.000000000 +0800
@@ -46,6 +46,7 @@
 import "PackageSystem";
 import "Mode";
 import "Stage";
+import "Storage";
 
 global boolean config_modified = false;
 
@@ -81,7 +82,7 @@
 
 /**
  * work around a bug in compiling ybc with UI as Y2Namespace
- *  #299258 
+ *  #299258
  */
 any dummy = UI::GetDisplayInfo();
 
@@ -92,14 +93,14 @@
 boolean Read_Configures()
 {
     boolean ret = false;
-    
+
     config_modified = false;
     defaults_items = $[];
     devices_items = [];
     multipaths_items = [];
     blacklist_items = [];
     blacklist_exception_items = [];
-    
+
 
     /* prepare for loading built-in configurations */
     SCR::Execute(.target.bash, "/sbin/multipath -t > " + builtin_multipath_conf_path);
@@ -175,14 +176,17 @@
 
     // BNC #418703
     // Checking and Installing packages only if needed (possible)
-    if (Mode::normal() && Stage::normal()) {
 	list<string> required_pack_list = ["multipath-tools", "device-mapper"];
+    if (Mode::normal() && Stage::normal()) {
 	ret = PackageSystem::CheckAndInstallPackagesInteractive (required_pack_list);
 	if (ret == false) {
 	    Report::Error(_("Cannot install required packages"));
 	    return false;
 	}
     } else {
+		import "PackagesProposal";
+		string proposal_ID = "multipath_proposal";
+		PackagesProposal::SetResolvables(proposal_ID, `package, required_pack_list);
 	y2milestone ("Not checking installed packages");
     }
 
@@ -194,9 +198,15 @@
     sleep(sl);
 
     /* read multipath service status */
-    service_status = (integer) SCR::Execute(.target.bash, "/etc/init.d/multipathd status");
-    if(service_status > 0)
-	service_status = 1;
+	if (Mode::normal() && Stage::normal()) {
+		service_status = (integer) SCR::Execute(.target.bash, "/etc/init.d/multipathd status");
+		if(service_status > 0)
+			service_status = 1;
+	} else {
+		service_status = (integer) SCR::Execute(.target.bash, "/bin/ps -A -o comm | grep -q multipathd");
+		if (service_status != 0)
+			service_status = 1;
+	}
     Progress::NextStep();
     sleep(sl);
 
@@ -266,13 +276,19 @@
 
     /* restart multipathd */
     Progress::NextStage ();
+
     if(service_status == 1) {
-	if( 0 != SCR::Execute(.target.bash, "/etc/init.d/multipathd restart")) {
-	    Report::Error(_("Restart multipathd failed."));
-	    return false;
+		if (Mode::normal() && Stage::normal()) {
+			if( 0 != SCR::Execute(.target.bash, "/etc/init.d/multipathd restart")) {
+				Report::Error(_("Restart multipathd failed."));
+				return false;
+			}
+		} else {
+			Storage::ActivateMultipath(false);
+			Storage::ActivateMultipath(true);
+		}
+		sleep(sl);
 	}
-	sleep(sl);
-    }
 
     /* Progress finished */
     Progress::NextStage();
@@ -330,6 +346,12 @@
     symbol current_tab = `status;
     integer interval_millisec = 50;
 
+	// Disable configure tab during installation
+	if (!(Mode::normal() && Stage::normal())) {
+		if (!has_dumbtab)
+			UI::ChangeWidget(`id(_("Configure")), `Enabled, false);
+	}
+
     while(true) {
 	ret = UI::TimeoutUserInput(interval_millisec);
 	interval_millisec = 5000;
@@ -356,6 +378,12 @@
 	    current_tab = `status;
 	    continue;
 	} else if (ret == _("Configure")) {
+		if (!(Mode::normal() && Stage::normal())) {
+			Popup::Message("Can't change configuration of multipath during installation");
+			if (has_dumbtab)
+				UI::ChangeWidget(`id(`tabs), `CurrentItem, _("Status"));
+			continue;
+		}
 	    Wizard::SetContentsButtons(caption, contents, HELPS["Configure_help"]:"",
 					Label::BackButton(), Label::FinishButton());
 	    Wizard::HideBackButton();
openSUSE Build Service is sponsored by