Add LVM2 VG member details to the Information dialog (#670171)
For LVM2 Physical Volumes display the Volume Group name and all the members in the Information dialog. Bug #670171 - Add LVM PV read-write support
This commit is contained in:
parent
1a62354995
commit
307f489177
|
@ -43,6 +43,7 @@ public:
|
|||
Byte_Value get_free_bytes( const Glib::ustring & path ) ;
|
||||
bool has_active_lvs( const Glib::ustring & path ) ;
|
||||
bool is_vg_exported( const Glib::ustring & vgname ) ;
|
||||
std::vector<Glib::ustring> get_vg_members( const Glib::ustring & vgname ) ;
|
||||
std::vector<Glib::ustring> get_error_messages( const Glib::ustring & path ) ;
|
||||
private:
|
||||
void initialize_if_required() ;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "../include/Dialog_Partition_Info.h"
|
||||
#include "../include/LVM2_PV_Info.h"
|
||||
|
||||
#include <gtkmm/separator.h>
|
||||
|
||||
namespace GParted
|
||||
{
|
||||
|
||||
|
@ -171,7 +173,8 @@ void Dialog_Partition_Info::Display_Info()
|
|||
{
|
||||
int top = 0, bottom = 1 ;
|
||||
Sector ptn_sectors = partition .get_sector_length() ;
|
||||
|
||||
LVM2_PV_Info lvm2_pv_info ;
|
||||
|
||||
Gtk::Table* table(manage(new Gtk::Table()));
|
||||
|
||||
table ->set_border_width( 5 ) ;
|
||||
|
@ -340,7 +343,6 @@ void Dialog_Partition_Info::Display_Info()
|
|||
}
|
||||
else if ( partition .filesystem == FS_LVM2_PV )
|
||||
{
|
||||
LVM2_PV_Info lvm2_pv_info ;
|
||||
Glib::ustring mount_point = partition .get_mountpoint() ;
|
||||
if ( mount_point .empty() )
|
||||
/* TO TRANSLATORS: Not active (Not a member of any volume group)
|
||||
|
@ -433,6 +435,48 @@ void Dialog_Partition_Info::Display_Info()
|
|||
1, 2,
|
||||
top++, bottom++,
|
||||
Gtk::FILL ) ;
|
||||
|
||||
if ( partition .filesystem == FS_LVM2_PV )
|
||||
{
|
||||
//one blank line
|
||||
table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//horizontal separator
|
||||
Gtk::HSeparator * hsep( manage( new Gtk::HSeparator() ) ) ;
|
||||
table ->attach( * hsep, 0, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//one blank line
|
||||
table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//Volume Group
|
||||
Glib::ustring vgname = lvm2_pv_info .get_vg_name( partition .get_path() ) ;
|
||||
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Volume Group:") ) + "</b>"),
|
||||
0, 1, top, bottom, Gtk::FILL ) ;
|
||||
table ->attach( * Utils::mk_label( vgname, true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
|
||||
1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
|
||||
//Members
|
||||
table ->attach( * Utils::mk_label( "<b>" + Glib::ustring( _("Members:") ) + "</b>"),
|
||||
0, 1, top, bottom, Gtk::FILL ) ;
|
||||
|
||||
std::vector<Glib::ustring> members ;
|
||||
if ( ! vgname .empty() )
|
||||
members = lvm2_pv_info .get_vg_members( vgname ) ;
|
||||
|
||||
if ( members .empty() )
|
||||
table ->attach( * Utils::mk_label( "" ), 1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
else
|
||||
{
|
||||
table ->attach( * Utils::mk_label( members [0], true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
|
||||
1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
for ( unsigned int i = 1 ; i < members .size() ; i ++ )
|
||||
{
|
||||
table ->attach( * Utils::mk_label( "" ), 0, 1, top, bottom, Gtk::FILL) ;
|
||||
table ->attach( * Utils::mk_label( members [i], true, Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false, true ),
|
||||
1, 2, top++, bottom++, Gtk::FILL ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dialog_Partition_Info::~Dialog_Partition_Info()
|
||||
|
|
|
@ -158,6 +158,37 @@ bool LVM2_PV_Info::is_vg_exported( const Glib::ustring & vgname )
|
|||
return false ;
|
||||
}
|
||||
|
||||
//Return vector of PVs which are members of the VG. Passing "" returns all empty PVs.
|
||||
std::vector<Glib::ustring> LVM2_PV_Info::get_vg_members( const Glib::ustring & vgname )
|
||||
{
|
||||
initialize_if_required() ;
|
||||
std::vector<Glib::ustring> members ;
|
||||
|
||||
//Generate array of unique PV member names of a VG
|
||||
for ( unsigned int i = 0 ; i < lvm2_pv_cache .size() ; i ++ )
|
||||
{
|
||||
if ( vgname == get_pv_attr_by_row( i, PVATTR_VG_NAME ) )
|
||||
{
|
||||
bool already_added = false ;
|
||||
Glib::ustring pvname = get_pv_attr_by_row( i, PVATTR_PV_NAME ) ;
|
||||
for ( unsigned int j = 0 ; j < members .size() ; j ++ )
|
||||
{
|
||||
if ( pvname == members[ j ] )
|
||||
{
|
||||
already_added = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( ! already_added )
|
||||
{
|
||||
members .push_back( get_pv_attr_by_row( i, PVATTR_PV_NAME ) ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return members ;
|
||||
}
|
||||
|
||||
std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages( const Glib::ustring & path )
|
||||
{
|
||||
initialize_if_required() ;
|
||||
|
|
Loading…
Reference in New Issue