libstorage-ng
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
storage::LvmVg Class Reference

A Volume Group of the Logical Volume Manager (LVM). More...

#include <LvmVg.h>

Inheritance diagram for storage::LvmVg:
[legend]
Collaboration diagram for storage::LvmVg:
[legend]

Public Member Functions

const std::string & get_vg_name () const
 Get volume group name.
 
void set_vg_name (const std::string &vg_name)
 Set the volume group name.
 
const Regionget_region () const
 Get the region of the volume group.
 
unsigned long long get_size () const
 Returns the size of the volume group in bytes.
 
std::string get_size_string () const
 Returns the size of the volume group as a localised string.
 
unsigned long long get_extent_size () const
 Returns the extent size of the volume group.
 
void set_extent_size (unsigned long long extent_size)
 Set the extent size of the volume group.
 
unsigned long long number_of_extents () const
 Returns the number of extents in the volume group.
 
unsigned long long number_of_used_extents () const
 Calculates the number of used extents in the volume group.
 
unsigned long long number_of_free_extents () const
 Calculates the number of free extents in the volume group.
 
bool is_overcommitted () const
 Check whether the volume group is overcommitted.
 
LvmPvadd_lvm_pv (BlkDevice *blk_device)
 Adds a block device as a physical volume to the volume group.
 
void remove_lvm_pv (BlkDevice *blk_device)
 Removes a block device from the volume group.
 
unsigned long long max_size_for_lvm_lv (LvType lv_type) const
 Return the max size in bytes for a new logical volume of type lv_type.
 
LvmLvcreate_lvm_lv (const std::string &lv_name, LvType lv_type, unsigned long long size)
 Create a logical volume with name lv_name and type lv_type in the volume group.
 
LvmLvcreate_lvm_lv (const std::string &lv_name, unsigned long long size) ST_DEPRECATED
 
void delete_lvm_lv (LvmLv *lvm_lv)
 Delete a logical volume in the volume group.
 
std::vector< LvmPv * > get_lvm_pvs ()
 Get all physical volumes of the volume group.
 
std::vector< const LvmPv * > get_lvm_pvs () const
 Get all physical volumes of the volume group.
 
LvmLvget_lvm_lv (const std::string &lv_name)
 
std::vector< LvmLv * > get_lvm_lvs ()
 Get all logical volumes of the volume group that are direct children of the volume group.
 
std::vector< const LvmLv * > get_lvm_lvs () const
 Get all logical volumes of the volume group that are direct children of the volume group.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual LvmVgclone () const override
 
 LvmVg (Impl *impl)
 
- Public Member Functions inherited from storage::Device
sid_t get_sid () const
 Return the storage id (sid) of the device.
 
bool operator== (const Device &rhs) const
 
bool operator!= (const Device &rhs) const
 
Devicecopy_to_devicegraph (Devicegraph *devicegraph) const
 Copies the device to the devicegraph.
 
bool exists_in_devicegraph (const Devicegraph *devicegraph) const
 Checks if the device exists in the devicegraph.
 
bool exists_in_probed () const
 Checks if the device exists in the probed devicegraph.
 
bool exists_in_staging () const
 Checks if the device exists in the staging devicegraph.
 
bool exists_in_system () const
 Checks if the device exists in the system devicegraph.
 
std::string get_displayname () const
 
ResizeInfo detect_resize_info () const
 Detect the resize info of the device.
 
bool has_children () const
 
size_t num_children () const
 
bool has_parents () const
 
size_t num_parents () const
 
std::vector< Device * > get_children ()
 
std::vector< const Device * > get_children () const
 
std::vector< Device * > get_children (View view)
 Get all children of the device.
 
std::vector< const Device * > get_children (View view) const
 Get all children of the device.
 
std::vector< Device * > get_parents ()
 
std::vector< const Device * > get_parents () const
 
std::vector< Device * > get_parents (View view)
 Get all parents of the device.
 
std::vector< const Device * > get_parents (View view) const
 Get all parents of the device.
 
std::vector< Device * > get_siblings (bool itself)
 
std::vector< const Device * > get_siblings (bool itself) const
 
std::vector< Device * > get_descendants (bool itself)
 
std::vector< const Device * > get_descendants (bool itself) const
 
std::vector< Device * > get_descendants (bool itself, View view)
 
std::vector< const Device * > get_descendants (bool itself, View view) const
 
std::vector< Device * > get_ancestors (bool itself)
 
std::vector< const Device * > get_ancestors (bool itself) const
 
std::vector< Device * > get_leaves (bool itself)
 
std::vector< const Device * > get_leaves (bool itself) const
 
std::vector< Device * > get_roots (bool itself)
 
std::vector< const Device * > get_roots (bool itself) const
 
std::vector< Holder * > get_in_holders ()
 
std::vector< const Holder * > get_in_holders () const
 
std::vector< Holder * > get_out_holders ()
 
std::vector< const Holder * > get_out_holders () const
 
void remove_descendants () ST_DEPRECATED
 
void remove_descendants (View view)
 Remove all descendants of the device.
 
const std::map< std::string, std::string > & get_userdata () const
 Return the userdata of the device.
 
void set_userdata (const std::map< std::string, std::string > &userdata)
 Set the userdata of the device.
 
std::string get_name_sort_key () const
 Get a sort-key based on the device name.
 
Devicegraphget_devicegraph ()
 Return the devicegraph the device belongs to.
 
const Devicegraphget_devicegraph () const
 Return the devicegraph the device belongs to.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
void save (xmlNode *node) const ST_DEPRECATED
 

Static Public Member Functions

static LvmVgcreate (Devicegraph *devicegraph, const std::string &vg_name)
 Create a device of type LvmVg.
 
static LvmVgload (Devicegraph *devicegraph, const xmlNode *node)
 
static bool is_valid_vg_name (const std::string &vg_name)
 Check whether a volume group name is valid.
 
static std::vector< LvmVg * > get_all (Devicegraph *devicegraph)
 Get all LvmVgs.
 
static std::vector< const LvmVg * > get_all (const Devicegraph *devicegraph)
 Get all LvmVgs.
 
static LvmVgfind_by_vg_name (Devicegraph *devicegraph, const std::string &vg_name)
 Find a volume group by vg-name.
 
static const LvmVgfind_by_vg_name (const Devicegraph *devicegraph, const std::string &vg_name)
 Find a volume group by vg-name.
 
static bool compare_by_vg_name (const LvmVg *lhs, const LvmVg *rhs)
 Compare (less than) two LvmVgs by vg-name.
 
- Static Public Member Functions inherited from storage::Device
static std::vector< Device * > get_all (Devicegraph *devicegraph)
 Get all Devices.
 
static std::vector< const Device * > get_all (const Devicegraph *devicegraph)
 Get all Devices.
 
static bool compare_by_sid (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by sid.
 
static bool compare_by_name (const Device *lhs, const Device *rhs)
 Compare (less than) two Devices by name.
 

Additional Inherited Members

- Protected Member Functions inherited from storage::Device
 Device (Impl *impl)
 
void create (Devicegraph *devicegraph) ST_DEPRECATED
 Create a device in the devicegraph.
 
void load (Devicegraph *devicegraph) ST_DEPRECATED
 

Detailed Description

A Volume Group of the Logical Volume Manager (LVM).

Member Function Documentation

◆ add_lvm_pv()

LvmPv * storage::LvmVg::add_lvm_pv ( BlkDevice * blk_device)

Adds a block device as a physical volume to the volume group.

If there is not a physical volume on the block device it will be created.

Exceptions
Exception

◆ clone()

virtual LvmVg * storage::LvmVg::clone ( ) const
overridevirtual

Implements storage::Device.

◆ compare_by_vg_name()

static bool storage::LvmVg::compare_by_vg_name ( const LvmVg * lhs,
const LvmVg * rhs )
static

Compare (less than) two LvmVgs by vg-name.

The comparison is locale unaware.

See also
get_vg_name()

◆ create()

static LvmVg * storage::LvmVg::create ( Devicegraph * devicegraph,
const std::string & vg_name )
static

Create a device of type LvmVg.

See also
Device::create(Devicegraph*)

◆ create_lvm_lv()

LvmLv * storage::LvmVg::create_lvm_lv ( const std::string & lv_name,
LvType lv_type,
unsigned long long size )

Create a logical volume with name lv_name and type lv_type in the volume group.

See also
LvType

◆ delete_lvm_lv()

void storage::LvmVg::delete_lvm_lv ( LvmLv * lvm_lv)

Delete a logical volume in the volume group.

Also deletes all descendants of the logical volume.

◆ find_by_vg_name() [1/2]

static const LvmVg * storage::LvmVg::find_by_vg_name ( const Devicegraph * devicegraph,
const std::string & vg_name )
static

Find a volume group by vg-name.

Exceptions
LvmVgNotFoundByVgName

◆ find_by_vg_name() [2/2]

static LvmVg * storage::LvmVg::find_by_vg_name ( Devicegraph * devicegraph,
const std::string & vg_name )
static

Find a volume group by vg-name.

Exceptions
LvmVgNotFoundByVgName

◆ get_all()

static std::vector< const LvmVg * > storage::LvmVg::get_all ( const Devicegraph * devicegraph)
static

Get all LvmVgs.

◆ get_extent_size()

unsigned long long storage::LvmVg::get_extent_size ( ) const

Returns the extent size of the volume group.

Returns
extent size

◆ get_lvm_lv()

LvmLv * storage::LvmVg::get_lvm_lv ( const std::string & lv_name)
Exceptions
Exception

◆ get_lvm_lvs() [1/2]

std::vector< LvmLv * > storage::LvmVg::get_lvm_lvs ( )

Get all logical volumes of the volume group that are direct children of the volume group.

E.g. thin logical volumes are not included here since those are children of the thin pool.

◆ get_lvm_lvs() [2/2]

std::vector< const LvmLv * > storage::LvmVg::get_lvm_lvs ( ) const

Get all logical volumes of the volume group that are direct children of the volume group.

E.g. thin logical volumes are not included here since those are children of the thin pool.

◆ get_lvm_pvs()

std::vector< const LvmPv * > storage::LvmVg::get_lvm_pvs ( ) const

Get all physical volumes of the volume group.

◆ get_region()

const Region & storage::LvmVg::get_region ( ) const

Get the region of the volume group.

The start of the region is always 0, the length is the number of extents and the block size in the extent size.

◆ get_size_string()

std::string storage::LvmVg::get_size_string ( ) const

Returns the size of the volume group as a localised string.

See also
get_size(), byte_to_humanstring()
Returns
size as string

◆ get_vg_name()

const std::string & storage::LvmVg::get_vg_name ( ) const

Get volume group name.

This is different from get_name().

◆ is_overcommitted()

bool storage::LvmVg::is_overcommitted ( ) const

Check whether the volume group is overcommitted.

If it is, Storage::commit() will most likely fail.

◆ is_valid_vg_name()

static bool storage::LvmVg::is_valid_vg_name ( const std::string & vg_name)
static

Check whether a volume group name is valid.

Does not check for collisions in /dev.

◆ max_size_for_lvm_lv()

unsigned long long storage::LvmVg::max_size_for_lvm_lv ( LvType lv_type) const

Return the max size in bytes for a new logical volume of type lv_type.

The size may be limited by other parameters, e.g. the filesystem on it. The max size also depends on parameters, e.g. the chunk size for thin pools.

◆ number_of_used_extents()

unsigned long long storage::LvmVg::number_of_used_extents ( ) const

Calculates the number of used extents in the volume group.

May be larger than the number of extents in the volume group.

◆ remove_lvm_pv()

void storage::LvmVg::remove_lvm_pv ( BlkDevice * blk_device)

Removes a block device from the volume group.

The physical volume on the block device will the deleted.

Exceptions
Exception

◆ set_extent_size()

void storage::LvmVg::set_extent_size ( unsigned long long extent_size)

Set the extent size of the volume group.

This can modify the size of the logical volumes. Due to rounding the size of logical volumes can become zero or the volume group can become overcommitted.

Setting the extent size is unsupported if the volume group is already created on-disk (it is only supported by LVM for special cases).

Exceptions
InvalidExtentSize,Exception

◆ set_vg_name()

void storage::LvmVg::set_vg_name ( const std::string & vg_name)

Set the volume group name.

The library does not support to rename volume groups on disk.

See also
get_vg_name()

The documentation for this class was generated from the following file: