Display VG export status with an LVM2 PVs busy status (#160787)
Also update to use LVM terminology, such that a Physical Volume is referred to as a member of a Volume Group. Status of an LVM2 PV is now displayed using one of the following messages: Not active (Not a member of any volume group) VGNAME not active VGNAME not active and exported VGNAME active Bug #160787 - lvm support
This commit is contained in:
parent
3fbdb8055f
commit
6d665d669d
|
@ -41,6 +41,7 @@ public:
|
||||||
Glib::ustring get_vg_name( const Glib::ustring & path ) ;
|
Glib::ustring get_vg_name( const Glib::ustring & path ) ;
|
||||||
Byte_Value get_free_bytes( const Glib::ustring & path ) ;
|
Byte_Value get_free_bytes( const Glib::ustring & path ) ;
|
||||||
bool has_active_lvs( 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_error_messages() ;
|
std::vector<Glib::ustring> get_error_messages() ;
|
||||||
private:
|
private:
|
||||||
void initialize_if_required() ;
|
void initialize_if_required() ;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../include/Dialog_Partition_Info.h"
|
#include "../include/Dialog_Partition_Info.h"
|
||||||
|
#include "../include/LVM2_PV_Info.h"
|
||||||
|
|
||||||
namespace GParted
|
namespace GParted
|
||||||
{
|
{
|
||||||
|
@ -269,7 +270,7 @@ void Dialog_Partition_Info::Display_Info()
|
||||||
else if ( partition .filesystem == FS_LVM2_PV )
|
else if ( partition .filesystem == FS_LVM2_PV )
|
||||||
{
|
{
|
||||||
/* TO TRANSLATORS: myvgname active
|
/* TO TRANSLATORS: myvgname active
|
||||||
* means that the partition is part of an LVM volume group and that
|
* means that the partition is a member of an LVM volume group and the
|
||||||
* volume group is active and being used by the operating system.
|
* volume group is active and being used by the operating system.
|
||||||
*/
|
*/
|
||||||
str_temp = String::ucompose( _("%1 active"), partition .get_mountpoint() ) ;
|
str_temp = String::ucompose( _("%1 active"), partition .get_mountpoint() ) ;
|
||||||
|
@ -300,17 +301,26 @@ void Dialog_Partition_Info::Display_Info()
|
||||||
}
|
}
|
||||||
else if ( partition .filesystem == FS_LVM2_PV )
|
else if ( partition .filesystem == FS_LVM2_PV )
|
||||||
{
|
{
|
||||||
|
LVM2_PV_Info lvm2_pv_info ;
|
||||||
Glib::ustring mount_point = partition .get_mountpoint() ;
|
Glib::ustring mount_point = partition .get_mountpoint() ;
|
||||||
if ( mount_point .empty() )
|
if ( mount_point .empty() )
|
||||||
/* TO TRANSLATORS: Not active (Not part of any volume group)
|
/* TO TRANSLATORS: Not active (Not a member of any volume group)
|
||||||
* means that the partition is not yet part of an LVM volume
|
* means that the partition is not yet a member of an LVM volume
|
||||||
* group and therefore is not active and can not yet be used by
|
* group and therefore is not active and can not yet be used by
|
||||||
* the operating system.
|
* the operating system.
|
||||||
*/
|
*/
|
||||||
str_temp = _("Not active (Not part of any volume group)") ;
|
str_temp = _("Not active (Not a member of any volume group)") ;
|
||||||
|
else if ( lvm2_pv_info .is_vg_exported( mount_point ) )
|
||||||
|
/* TO TRANSLATORS: myvgname not active and exported
|
||||||
|
* means that the partition is a member of an LVM volume group but
|
||||||
|
* the volume group is not active and not being used by the operating system.
|
||||||
|
* The volume group has also been exported making the LVM physical volumes
|
||||||
|
* ready for moving to a different computer system.
|
||||||
|
*/
|
||||||
|
str_temp = String::ucompose( _("%1 not active and exported"), mount_point ) ;
|
||||||
else
|
else
|
||||||
/* TO TRANSLATORS: myvgname not active
|
/* TO TRANSLATORS: myvgname not active
|
||||||
* means that the partition is part of an LVM volume group but
|
* means that the partition is a member of an LVM volume group but
|
||||||
* the volume group is not active and not being used by the operating system.
|
* the volume group is not active and not being used by the operating system.
|
||||||
*/
|
*/
|
||||||
str_temp = String::ucompose( _("%1 not active"), mount_point ) ;
|
str_temp = String::ucompose( _("%1 not active"), mount_point ) ;
|
||||||
|
|
|
@ -25,8 +25,9 @@ enum PV_ATTRIBUTE
|
||||||
PVATTR_PV_NAME = 0,
|
PVATTR_PV_NAME = 0,
|
||||||
PVATTR_PV_FREE = 1,
|
PVATTR_PV_FREE = 1,
|
||||||
PVATTR_VG_NAME = 2,
|
PVATTR_VG_NAME = 2,
|
||||||
PVATTR_LV_NAME = 3,
|
PVATTR_VG_BITS = 3,
|
||||||
PVATTR_LV_BITS = 4
|
PVATTR_LV_NAME = 4,
|
||||||
|
PVATTR_LV_BITS = 5
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
//Data model:
|
//Data model:
|
||||||
|
@ -35,17 +36,20 @@ enum PV_ATTRIBUTE
|
||||||
// lvm_found - Is the "lvm" command available?
|
// lvm_found - Is the "lvm" command available?
|
||||||
// lvm2_pv_cache - String vector storing attributes of a PV.
|
// lvm2_pv_cache - String vector storing attributes of a PV.
|
||||||
// Attributes are: pv_name,pv_free,vg_name,
|
// Attributes are: pv_name,pv_free,vg_name,
|
||||||
// lv_name,lv_attr. Pv_free is the number of
|
// vg_attr,lv_name,lv_attr. Pv_free is the
|
||||||
// free bytes, see lvs(8) for details of
|
// number of free bytes, see vgs(8) and lvs(8)
|
||||||
// lv_attrs.
|
// for details of vg_attr and lv_attr
|
||||||
|
// respectively.
|
||||||
// E.g.
|
// E.g.
|
||||||
// ["/dev/sda10,2147483648,,,",
|
// ["/dev/sda10,2147483648,,r-----,,",
|
||||||
// "/dev/sda11,2143289344,GParted-VG1,,",
|
// "/dev/sda11,2143289344,GParted-VG1,wz--n-,,",
|
||||||
// "/dev/sda12,1619001344,GParted-VG2,lvol0,-wi---",
|
// "/dev/sda12,1619001344,GParted-VG2,wz--n-,lvol0,-wi---",
|
||||||
// "/dev/sda12,1619001344,GParted-VG2,,",
|
// "/dev/sda12,1619001344,GParted-VG2,wz--n-,,",
|
||||||
// "/dev/sda13,830472192,GParted_VG3,lvol0,-wi-a-",
|
// "/dev/sda13,830472192,GParted_VG3,wz--n-,lvol0,-wi-a-",
|
||||||
// "/dev/sda13,830472192,GParted_VG3,lvol1,-wi-a-",
|
// "/dev/sda13,830472192,GParted_VG3,wz--n-,lvol1,-wi-a-",
|
||||||
// "/dev/sda13,830472192,GParted_VG3,,"]
|
// "/dev/sda13,830472192,GParted_VG3,wz--n-,,",
|
||||||
|
// "/dev/sda14,1828716544,GParted-VG4,wzx-n-,lvol0,-wi---",
|
||||||
|
// "/dev/sda14,1828716544,GParted-VG4,wzx-n-,,"]
|
||||||
// error_messages - String vector storing error messsages.
|
// error_messages - String vector storing error messsages.
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +134,29 @@ bool LVM2_PV_Info::has_active_lvs( const Glib::ustring & path )
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Report if the VG is exported.
|
||||||
|
bool LVM2_PV_Info::is_vg_exported( const Glib::ustring & vgname )
|
||||||
|
{
|
||||||
|
initialize_if_required() ;
|
||||||
|
|
||||||
|
for ( unsigned int i = 0 ; i < lvm2_pv_cache .size() ; i ++ )
|
||||||
|
{
|
||||||
|
std::vector<Glib::ustring> pv_attrs ;
|
||||||
|
Utils::split( lvm2_pv_cache [i], pv_attrs, "," ) ;
|
||||||
|
if ( vgname == get_pv_attr_by_row( i, PVATTR_VG_NAME ) )
|
||||||
|
{
|
||||||
|
Glib::ustring vg_bits = get_pv_attr_by_row( i, PVATTR_VG_BITS ) ;
|
||||||
|
//3rd "bit" is export status. E.g.
|
||||||
|
// "wz--n-" imported, "wzx-n-" exported.
|
||||||
|
// Treat any non-hyphen character as exported.
|
||||||
|
if ( vg_bits .length() >= 3 && vg_bits [2] != '-' )
|
||||||
|
//VG is exported
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages()
|
std::vector<Glib::ustring> LVM2_PV_Info::get_error_messages()
|
||||||
{
|
{
|
||||||
initialize_if_required() ;
|
initialize_if_required() ;
|
||||||
|
@ -169,7 +196,7 @@ void LVM2_PV_Info::load_lvm2_pv_info_cache()
|
||||||
|
|
||||||
//Load LVM2 PV attribute cache. Output PV attributes in
|
//Load LVM2 PV attribute cache. Output PV attributes in
|
||||||
// PV_ATTRIBUTE order
|
// PV_ATTRIBUTE order
|
||||||
Glib::ustring cmd = "lvm pvs --config \"log{command_names=0}\" --nosuffix --noheadings --separator , --units b -o pv_name,pv_free,vg_name,lv_name,lv_attr" ;
|
Glib::ustring cmd = "lvm pvs --config \"log{command_names=0}\" --nosuffix --noheadings --separator , --units b -o pv_name,pv_free,vg_name,vg_attr,lv_name,lv_attr" ;
|
||||||
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
||||||
{
|
{
|
||||||
if ( output != "" )
|
if ( output != "" )
|
||||||
|
|
Loading…
Reference in New Issue