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_evms.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
9KB
|
353 lines
/**
* File:
* inst_evms.ycp
*
* Module:
* evms
*
* Summary:
*
* Authors:
* Thomas Fehr <fehr@suse.de>
*
*
*
* $Id: inst_evms.ycp 33372 2006-10-12 16:13:30Z fehr $
*
*/
{
textdomain "storage";
import "Installation";
import "Mode";
import "Storage";
import "Wizard";
import "Label";
include "partitioning/partition_defines.ycp";
include "partitioning/custom_part_dialogs.ycp";
include "partitioning/custom_part_lib.ycp";
include "partitioning/custom_part_check_generated.ycp";
include "partitioning/evms_lib.ycp";
map<string,map> targetMap = Storage::GetTargetMap();
string no_container = "-none-";
boolean changed = false;
Storage::CreateTargetBackup("evms");
y2milestone( "evms:%1", targetMap["/dev/evms","partitions"]:[] );
y2milestone( "evms co:%1", size(filter(string k, map e, targetMap,
``(e["is_container"]:false))));
if( size(targetMap["/dev/evms","partitions"]:[])==0 )
{
Storage::ActivateEvms();
targetMap = Storage::GetTargetMap();
y2milestone( "evms:%1", targetMap["/dev/evms","partitions"]:[] );
y2milestone( "evms co:%1", size(filter(string k, map e, targetMap,
``(e["is_container"]:false))));
}
foreach( string k, map e, targetMap,
``{
if( e["type"]:`CT_UNKNOWN==`CT_LVM &&
find( map p, e["partitions"]:[], ``(p["mount"]:""=="swap"))!=nil )
{
changed = true;
y2milestone( "k %1", k );
targetMap[k,"partitions"] =
maplist( map p, e["partitions"]:[],
``{
if( p["mount"]:""=="swap" )
p["mount"] = "";
return( p );
});
y2milestone( "k part %1", targetMap[k,"partitions"]:[] );
}
});
foreach( string k, map e, targetMap,
``{
if( changed && e["type"]:`CT_UNKNOWN==`CT_EVMS &&
e["is_container"]:false )
{
y2milestone( "k %1", k );
targetMap[k,"partitions"] =
maplist( map p, e["partitions"]:[],
``{
if( Stage::initial() && p["detected_fs"]:`unknown==`swap )
{
p["mount"] = "swap";
}
return( p );
});
y2milestone( "k part %1", targetMap[k,"partitions"]:[] );
}
});
if( changed )
Storage::SetTargetMap( targetMap );
list evms_cont = get_containers( targetMap, no_container );
list table = [];
string current_co = evms_cont[0]:"";
term dlg =
`HBox(
`HSpacing(2.5),
`VBox(
`VSpacing(0.1),
`VWeight( 20,
`HBox(
`VBox(
get_bargraph_if_possible(),
`HBox(
`Left(`ReplacePoint(
`id(`rcont),
`ComboBox(`id(`cont), `opt(`notify),
// button text
_("EVMS &Container"),
[] ))),
`HSpacing(2),
// label text
`VBox( `Left(`Label(_("Size"))),
// label text
`Left(`Label(_("Available")))),
`VBox( `Left(`Label( `id(`co_size),
`opt(`hstretch,
`outputField),
"" )),
`Left(`Label( `id(`co_free),
`opt(`hstretch,
`outputField),
"" )))
)
),
`HWeight(1,`HStretch()),
`HSpacing(2),
`VCenter(`Right(
`VBox(
`PushButton( `id(`add_container),
`opt(`hstretch),
// button text
_("C&reate Container")),
`PushButton( `id(`edit_container),
`opt(`hstretch),
// button text
_("&Edit Container")),
`PushButton( `id(`remove_container),
`opt(`hstretch),
// button text
_("&Remove Container"))
)))
)
),
`VSpacing(1),
`VWeight( 50,
`VBox(
`Table( `id(`evms_table), `opt(`notify),
// table header text
`header(_("Device"), `Right(_(" Size")),
`Center(_("Format")), _(" Mount"),
`Center(_("Type"))), [] ),
`VSpacing(0.2),
// button text
`HBox( `PushButton(`id(`evms_add), _("A&dd")),
// button text
`PushButton(`id(`evms_edit), _("&Edit")),
// button text
`PushButton(`id(`evms_delete), _("&Remove"))
// button text
//`PushButton(`id(`evms_convert), _("C&onvert"))
),
`VSpacing(0.5)
)
)
),
`HSpacing(2)
);
// heading text
Wizard::SetContents( _("EVMS Configuration"), dlg, "", true, true);
Wizard::SetHelpText( getEvmsHelptext() );
// Display current container:
new_co_list( evms_cont );
UI::ChangeWidget( `id(`cont), `Value, current_co );
map co = get_co_map( current_co, targetMap );
y2milestone( "current_co:%1 co:%2", current_co, co );
new_co_size( co );
//////////////////////////////////////////////////////////////////////
// mainloop
//////////////////////////////////////////////////////////////////////
string id = "";
symbol ret = `next;
changed = false;
repeat
{
/////////////////////////////////////////////////////////////////
// Show the current state:
table = get_evms_volumes( targetMap );
UI::ChangeWidget( `id(`evms_table), `Items, table);
UI::SetFocus(`id(`evms_table));
if( id!=nil && id != "" )
{
UI::ChangeWidget( `id(`evms_table), `CurrentItem, id);
}
/////////////////////////////////////////////////////////////////
// Wait for User input
ret = (symbol)Wizard::UserInput();
////////////////////////////////////////
// user has changed the current volume group
////////////////////////////////////////
if( ret == `cont )
{
current_co = (string)UI::QueryWidget( `id(`cont), `Value);
y2milestone("TTT %1", current_co );
co = get_co_map( current_co, targetMap );
new_co_size( co );
}
////////////////////////////////////////
// Add a new container:
////////////////////////////////////////
if( ret == `add_container )
{
map ad = add_evms_container( targetMap );
targetMap = Storage::GetTargetMap();
// has the user cancelled the dialog?
if( ad["ok"]:false )
{
changed = true;
evms_cont = get_containers( targetMap, no_container );
new_co_list( evms_cont );
current_co = ad["name"]:"";
UI::ChangeWidget( `id(`cont), `Value, current_co );
co = get_co_map( current_co, targetMap );
new_co_size( co );
}
}
else if( ret == `edit_container && current_co!=no_container )
{
map ad = edit_evms_container( targetMap, current_co );
targetMap = Storage::GetTargetMap();
// has the user cancelled the dialog?
if( ad["ok"]:false )
{
changed = true;
evms_cont = get_containers( targetMap, no_container );
new_co_list( evms_cont );
current_co = ad["name"]:"";
UI::ChangeWidget( `id(`cont), `Value, current_co );
co = get_co_map( current_co, targetMap );
new_co_size( co );
}
}
////////////////////////////////////////
// Remove volume group:
////////////////////////////////////////
else if( ret == `remove_container && current_co!=no_container )
{
map ad = remove_evms_container( targetMap, current_co );
if( ad["ok"]:false )
{
changed = true;
targetMap = Storage::GetTargetMap();
evms_cont = get_containers( targetMap, no_container );
new_co_list( evms_cont );
current_co = evms_cont[0]:"";
UI::ChangeWidget( `id(`cont), `Value, current_co );
co = get_co_map( current_co, targetMap );
new_co_size( co );
}
}
else if( ret == `evms_add && current_co != no_container )
{
map ad = add_evms_volume( current_co, targetMap );
// has the user cancelled the dialog?
if( ad["ok"]:false )
{
targetMap = Storage::GetTargetMap();
co = get_co_map( current_co, targetMap );
changed = true;
new_co_size( co );
}
}
else if( ret == `evms_edit )
{
id = (string)UI::QueryWidget(`id(`evms_table), `CurrentItem);
map ad = edit_evms_volume( id, targetMap );
// has the user cancelled the dialog?
if( ad["ok"]:false )
{
targetMap = Storage::GetTargetMap();
co = get_co_map( current_co, targetMap );
changed = true;
new_co_size( co );
}
}
else if( ret == `evms_delete )
{
id = (string)UI::QueryWidget(`id(`evms_table), `CurrentItem);
map ad = delete_evms_volume( id, targetMap );
// has the user cancelled the dialog?
if( ad["ok"]:false )
{
targetMap = Storage::GetTargetMap();
co = get_co_map( current_co, targetMap );
changed = true;
new_co_size( co );
id = "";
}
}
////////////////////////////////////////
// Finish this step
////////////////////////////////////////
if( ret == `back || ret == `cancel || ret == `abort )
{
if( changed )
{
// popup text
string txt = _("You have changed the EVMS configuration.
These changes will be lost if you exit the dialog now.
Continue?
");
if( !Popup::ContinueCancel( txt ))
{
ret = `again;
}
else
{
Storage::RestoreTargetBackup("evms");
}
}
}
}
until (ret == `next || ret == `back || ret == `cancel || ret == `abort );
if( !changed )
Storage::RestoreTargetBackup("evms");
Storage::DisposeTargetBackup("evms");
return ret;
}
// end