ACC SHELL
/**
* File: ep-lvm.ycp
* Package: yast2-storage
* Summary: Expert Partitioner
* Authors: Arvin Schnell <aschnell@suse.de>
*
* This file must only be included in other Expert Partitioner files ("ep-*.ycp").
*/
{
textdomain "storage";
include "partitioning/ep-lvm-dialogs.ycp";
include "partitioning/ep-lvm-lib.ycp";
void EpContextMenuLvmVg(string device)
{
symbol widget = ContextMenu::Simple([ `item(`id(`add), `icon(StorageIcons::lvm_lv_icon), _("Add Logical Volume")),
`item(`id(`resize), _("Resize")),
`item(`id(`delete), _("Delete")) ]);
switch (widget)
{
case `add:
EpCreateLogicalVolume(device);
break;
case `resize:
EpResizeVolumeGroup(device);
break;
case `delete:
EpDeleteVolumeGroup(device);
break;
}
}
void EpContextMenuLvmLv(string device)
{
symbol widget = ContextMenu::Simple([ `item(`id(`edit), _("Edit")),
`item(`id(`resize), _("Resize")),
`item(`id(`delete), _("Delete")) ]);
switch (widget)
{
case `edit:
EpEditLogicalVolume(device);
break;
case `resize:
EpResizeLogicalVolume(device);
break;
case `delete:
EpDeleteLogicalVolume(device, `table);
break;
}
}
term LvmButtonBox()
{
return `HBox(
// push button text
`PushButton(`id(`edit),`opt(`key_F4), _("Edit...")),
// push button text
`PushButton(`id(`resize), `opt(`key_F6), _("Resize...")),
// push button text
`PushButton(`id(`delete), `opt(`key_F5), _("Delete..."))
);
}
void HandleLvmButtons( any user_data, string device, map event )
{
string vg = "";
boolean is_vg = false;
if (user_data == nil)
{
map<string, map> target_map = Storage::GetTargetMap();
map disk = nil;
map part = nil;
SplitDevice(target_map, device, disk, part);
vg = disk["device"]:"";
is_vg = part == nil;
}
else
{
vg = (string) user_data;
}
switch (Event::IsWidgetActivated(event))
{
case `add:
EpCreateLogicalVolume( vg );
break;
case `edit:
if (is_vg)
TreePanel::SwitchToNew( vg );
else
EpEditLogicalVolume( device );
break;
case `resize:
if (is_vg)
EpResizeVolumeGroup( device);
else
EpResizeLogicalVolume ( device );
break;
case `delete:
if (is_vg)
EpDeleteVolumeGroup( device );
else
EpDeleteLogicalVolume ( device, UI::WidgetExists(`id(`table)) ? `table : `overview );
break;
}
switch (Event::IsMenu( event ))
{
case `group:
EpCreateVolumeGroup();
break;
case `volume:
EpCreateLogicalVolume( vg );
break;
}
}
void CreateLvmMainPanel(any user_data)
{
symbol Predicate(map disk, map partition)
{
return StorageFields::PredicateDiskType(disk, partition, [`CT_LVM]);
}
list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `format, `encrypted, `type,
`fs_type, `label, `mount_point, `mount_by,
`used_by, `lvm_metadata, `pe_size, `stripes ]);
map<string, map> target_map = Storage::GetTargetMap();
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
list <term> mb_items = [ `item(`id(`group), _("Volume Group")) ];
if ( !isempty(table_contents) )
mb_items = add( mb_items, `item(`id(`volume), _("Logical Volume")) );
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// heading
`IconAndHeading(_("Volume Management"), StorageIcons::lvm_icon),
`Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
`MenuButton(`id(`add), `opt(`key_F3), _("Add..."), mb_items),
LvmButtonBox(),
`HStretch()
)
)
)
);
// helptext
string helptext = _("<p>This view shows all LVM volume groups and
their logical volumes.</p>");
Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
}
void HandleLvmMainPanel(any user_data, map event)
{
string device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
HandleLvmButtons( user_data, device, event );
switch (Event::IsWidgetContextMenuActivated(event))
{
case `table:
EpContextMenuDevice(device);
break;
}
UI::SetFocus(`id(`table));
}
void CreateLvmVgOverviewTab(any user_data)
{
string device = (string) user_data;
map<string, map> target_map = Storage::GetTargetMap();
list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size,
`heading_lvm, `lvm_metadata, `pe_size ]);
UI::ReplaceWidget(`tab_panel,
`VBox(
StorageFields::Overview(fields, target_map, device)
)
);
// helptext
string helptext = _("<p>This view shows detailed information about the
selected volume group.</p>");
Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
}
void HandleLvmVgOverviewTab(any user_data, map event)
{
string device = (string) user_data;
HandleLvmButtons( nil, device, event );
UI::SetFocus(`id(`text));
}
void CreateLvmVgLvsTab(any user_data)
{
string device = (string) user_data;
symbol Predicate(map disk, map partition)
{
return StorageFields::PredicateDiskDevice(disk, partition, [ device ]);
}
list<symbol> fields = StorageSettings::FilterTable([ `device, `size, `format, `encrypted, `type,
`fs_type, `label, `mount_point, `mount_by,
`used_by, `stripes ]);
map<string, map> target_map = Storage::GetTargetMap();
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
DiskBarGraph(device),
`Table(`id(`table), `opt(`keepSorting, `notify, `notifyContextMenu),
table_header, table_contents),
`HBox(
// push button text
`PushButton(`id(`add), `opt(`key_F3), _("Add...")),
LvmButtonBox(),
`HStretch()
)
)
);
// helptext
string helptext = _("<p>This view shows all logical volumes of the
selected volume group.</p>");
Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
}
void HandleLvmVgLvsTab(any user_data, map event)
{
string vg_device = (string) user_data;
string lv_device = (string) UI::QueryWidget(`id(`table), `CurrentItem);
HandleLvmButtons( vg_device, lv_device, event );
switch (Event::IsWidgetContextMenuActivated(event))
{
case `table:
EpContextMenuDevice(lv_device);
break;
}
UI::SetFocus(`id(`table));
}
void CreateLvmVgPvsTab(any user_data)
{
string disk_device = (string) user_data;
symbol Predicate(map disk, map partition)
{
return StorageFields::PredicateUsedByDevice(disk, partition, [ disk_device ]);
}
list<symbol> fields = StorageSettings::FilterTable([ `device, `udev_path, `udev_id, `size,
`format, `encrypted, `type, `used_by ]);
map<string, map> target_map = Storage::GetTargetMap();
term table_header = StorageFields::TableHeader(fields);
list<term> table_contents = StorageFields::TableContents(fields, target_map, Predicate);
UI::ReplaceWidget(`tab_panel,
`VBox(
`Table(`id(`table), `opt(`keepSorting, `notify),
table_header, table_contents)
)
);
// helptext
string helptext = _("<p>This view shows all physical volumes used by
the selected volume group.</p>");
Wizard::RestoreHelp(helptext + StorageFields::TableHelptext(fields));
}
void CreateLvmVgPanel(any user_data)
{
string device = (string) user_data;
map<symbol, map> data = $[ `overview : $[ `create : CreateLvmVgOverviewTab, `handle : HandleLvmVgOverviewTab, `user_data : user_data ],
`lvs : $[ `create : CreateLvmVgLvsTab, `handle : HandleLvmVgLvsTab, `user_data : user_data ],
`pvs : $[ `create : CreateLvmVgPvsTab, `user_data : user_data ] ];
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
// heading
`IconAndHeading(sformat(_("Volume Group: %1"), device), StorageIcons::lvm_icon),
`DumbTab(`id(`tab), [
// push button text
`item(`id(`overview), _("&Overview")),
// push button text
`item(`id(`lvs), _("&Logical Volumes")),
// push button text
`item(`id(`pvs), _("&Physical Volumes"))
],
`ReplacePoint(`id(`tab_panel), TabPanel::empty_panel)
)
))
);
TabPanel::Init(data, `lvs);
}
void HandleLvmVgPanel(any user_data, map event)
{
TabPanel::Handle(event);
}
void CreateLvmLvPanel(any user_data)
{
string device = (string) user_data;
map<string, map> target_map = Storage::GetTargetMap();
list<symbol> fields = StorageSettings::FilterOverview([ `heading_device, `device, `size, `encrypted,
`used_by, `heading_lvm, `stripes,
`heading_filesystem, `fs_type, `mount_point,
`mount_by, `uuid, `label ]);
UI::ReplaceWidget(`tree_panel,
Greasemonkey::Transform(
`VBox(
`HStretch(),
// heading
`IconAndHeading(sformat(_("Logical Volume: %1"), device), StorageIcons::lvm_lv_icon),
StorageFields::Overview(fields, target_map, device),
`HBox(
LvmButtonBox(),
`HStretch()
)
)
)
);
// helptext
string helptext = _("<p>This view shows detailed information about the
selected logical volume.</p>");
Wizard::RestoreHelp(helptext + StorageFields::OverviewHelptext(fields));
}
void HandleLvmLvPanel(any user_data, map event)
{
string device = (string) user_data;
HandleLvmButtons( nil, device, event );
UI::SetFocus (`id(`text));
}
}
ACC SHELL 2018