home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
clients
/
inst_part_proposal.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
9KB
|
304 lines
/*
*************************************************************
*
* YaST2 SuSE Labs -o)
* -------------------- /\\
* _\_v
* www.suse.de / www.suse.com
* ----------------------------------------------------------
*
* Author: Michael Hager <mike@suse.de>
*
* Description: Create a proposal for partitioning
*
*
*
*
*
*************************************************************
$Id: inst_part_proposal.ycp 32967 2006-09-19 11:13:25Z fehr $
*/
{
textdomain "storage";
import "Arch";
import "Wizard";
import "Mode";
import "Popup";
import "Storage";
include "partitioning/custom_part_check_generated.ycp";
include "partitioning/do_proposal_flexible.ycp";
boolean test_mode = Mode::test ();
boolean demo_mode = Mode::test ();
string part_proposal_mode = Storage::GetPartProposalMode();
map<string,map> targetMap = Storage::GetTargetMap();
boolean run_in_testsuite = Storage::GetTestsuite();
boolean proposal_firsttime = Storage::GetPartProposalFirst();
boolean orig_proposal_firsttime = proposal_firsttime;
boolean no_suggestion_possible = true;
if ( test_mode && (size(targetMap) == 0) )
{
if ( demo_mode ) {
y2warning("***** Demo mode active - using fake demo values *****");
targetMap = (map<string,map>)SCR::Read(.target.yast2, "demo_target_map.ycp");
}
else {// ! demo_mode
y2warning("***** Test mode active - using fake values *****");
targetMap = (map<string,map>)SCR::Read(.target.yast2, "test_target_map.ycp");
}
Storage::SetTargetMap( targetMap );
}
//////////////////////////////////////////////////////
// This module is only for i386 fdisk-label
if ( Arch::s390 () )
{
return Storage::GetExitKey();
}
// ///////////// DELETE THIS LINE FOR PRODUCTIOIN VERSION
//
// proposal_firsttime = true;
// orig_proposal_firsttime = true;
string title = "";
string accept_str = "";
string modify_str = "";
string detailed_str = "";
string lvm_str = "";
string evms_str = "";
// Title for dialogue
title = _("Suggested Partitioning");
// Radiobutton for partition dialog
accept_str = _("&Accept Proposal");
// Radiobutton for partition dialog
modify_str = _("Ba&se Partition Setup on This Proposal");
// Radiobutton for partition dialog
detailed_str = _("&Create Custom Partition Setup");
// Radiobutton for partition dialog
lvm_str = _("Create &LVM Based Proposal");
// Radiobutton for partition dialog
evms_str = _("Create &EVMS Based Proposal");
string changes = Storage::ChangeText();
y2milestone( "current proposal: %1", changes );
if( size(changes) == 0 )
{
changes = "<p></p>" +
// popup text, richtext format
_("<p>You rejected the proposal. Use one of the options to continue partitioning.</p>");
}
map cfg = Storage::GetControlCfg();
term bframe =
`VBox(
`VSpacing (0.2),
`Left( `RadioButton (`id ("accept"), accept_str, part_proposal_mode=="accept")),
`VSpacing (0.2),
`Left( `RadioButton (`id ("modify"), modify_str, part_proposal_mode=="modify")),
`VSpacing (0.2),
`Left( `RadioButton (`id ("detailed"), detailed_str, part_proposal_mode=="detailed")),
`VSpacing (0.2),
`Left( `RadioButton (`id ("lvm"), lvm_str, false ))
);
if( cfg["evms_config"]:false )
{
bframe = add( bframe, `VSpacing (0.2) );
bframe = add( bframe,
`Left( `RadioButton (`id ("evms"), evms_str, false )) );
}
// Frame description in suggested partition for mode accept modify ..
bframe = `HCenter( `Frame( _("Partitioning"), `HVSquash( bframe ) ));
term contents =
`VBox (
`VSpacing (0.5),
`HBox (
`HSpacing (2),
`RadioButtonGroup (`id ("part_option"),
`VBox (
`MinHeight( 7, `RichText (`id ("richtext"), changes)),
`VSpacing(1),
bframe,
`VStretch()
)),
`HSpacing (2)
),
`VSpacing(2) );
// help on suggested partitioning
string help_text = _("<p>
Your hard disks have been checked. The partition setup
displayed is proposed for your hard drive.</p>");
// help text continued
// %1 is replaced by button text
help_text = help_text + sformat(_("<p>
To accept these suggestions and continue, select
<b>%1</b>.</p>
"), deletechars(accept_str,"&"));
// help text continued
// %1 is replaced by button text
help_text = help_text + sformat(_("<p>
If you want to do only small adjustments to the proposed
setup (like e.g. changing filesystem types) choose
<b>%1</b> and do these modification in expert
partioner dialog.</p>
"), deletechars(modify_str,"&"));
// help text continued
help_text = help_text + sformat(_("<p>
If the suggestion does not fit your needs, create
your own partition setup starting with the partitions as
currently present on the disks. For this, select
<b>%1</b>.
This is also the option to choose for
advanced options like RAID and encryption.</p>
"), deletechars(detailed_str,"&"));
if( cfg["evms_config"]:false )
// help text continued
// %1 is replaced by button text
help_text = help_text + _("<p>
To create a LVM or EVMS based proposal choose the corresponding button.</p>");
else
// help text continued
// %1 is replaced by button text
help_text = help_text + _("<p>
To create a LVM based proposal choose the corresponding button.</p>");
if( proposal_firsttime )
{
map prop = get_inst_prop( Storage::GetTargetMap() );
proposal_firsttime = false;
no_suggestion_possible = !prop["ok"]:false;
if( !no_suggestion_possible )
{
targetMap = prop["target"]:$[];
}
}
symbol ret = nil;
if( !run_in_testsuite )
{
/////////////////////////////////////////////////////////////////////
// next step to visualize the hit the new target map from hit
if( no_suggestion_possible && orig_proposal_firsttime )
{
y2milestone( "Could not create a proposal %1 %2 ",
no_suggestion_possible, orig_proposal_firsttime );
return( Storage::GetExitKey() );
}
else
{
Wizard::SetContents( title, contents, help_text,
(boolean)WFM::Args(0), (boolean)WFM::Args(1) );
if ( Stage::initial () )
Wizard::SetTitleIcon( "yast-partitioning" );
}
repeat
{
Wizard::SetFocusToNextButton();
ret = (symbol)Wizard::UserInput();
y2milestone( "USERINPUT %1", ret );
string part_proposal_mode =
(string) UI::QueryWidget(`id("part_option"), `CurrentButton);
if( ret == `abort && Popup::ReallyAbort(true) )
return `abort;
if( ret != `back )
{
Storage::SetPartProposalFirst( false );
string target_is = "";
Storage::SetPartProposalMode( part_proposal_mode );
if( part_proposal_mode == "accept" )
{
target_is = "SUGGESTION";
}
else if( part_proposal_mode == "lvm" ||
part_proposal_mode == "evms" )
{
target_is = "SUGGESTION";
if( part_proposal_mode=="lvm" )
Storage::SetProposalLvm(true);
else
Storage::SetProposalEvms(true);
Storage::ResetOndiskTarget();
Storage::AddMountPointsForWin(Storage::GetTargetMap());
map prop = get_inst_prop( Storage::GetTargetMap());
if( !prop["ok"]:false )
{
Popup::Error( _("Impossible to create the reuquested proposal.") );
ret = `doagain;
}
else
{
targetMap = prop["target"]:$[];
Storage::SetPartProposalMode( "accept" );
Storage::SetPartProposalActive( true );
}
Storage::SetProposalDefault();
}
else if( part_proposal_mode == "modify" )
{
target_is = "PROP_MODIFY";
}
else if( part_proposal_mode == "detailed" )
{
if( Storage::GetPartMode()!="CUSTOM" )
{
target_is = "NORMAL";
}
else
{
target_is = "CUSTOM";
}
Storage::SetPartDisk( "" );
}
y2milestone( "target_is %1", target_is );
if( ret != `doagain )
{
Storage::SetPartMode( target_is );
Storage::SetTargetMap( targetMap );
}
}
} until ( ret == `next || ret == `back || ret == `cancel );
}
Storage::SaveExitKey( ret );
return ret;
}