libstorage-ng
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
storage::Md Class Reference

A MD device. More...

#include <Md.h>

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

Public Member Functions

MdUseradd_device (BlkDevice *blk_device)
 
void remove_device (BlkDevice *blk_device)
 
std::vector< BlkDevice * > get_devices ()
 
std::vector< const BlkDevice * > get_devices () const
 
bool is_numeric () const
 Returns true if the name of the MD is numeric.
 
unsigned int get_number () const
 Returns the number of the MD. More...
 
MdLevel get_md_level () const
 
void set_md_level (MdLevel md_level)
 
MdParity get_md_parity () const
 Get the parity of the MD RAID. More...
 
void set_md_parity (MdParity md_parity)
 Set the parity of the MD RAID. More...
 
std::vector< MdParity > get_allowed_md_parities () const
 Get the allowed parities for the MD RAID. More...
 
unsigned long get_chunk_size () const
 
void set_chunk_size (unsigned long chunk_size)
 
const std::string & get_uuid () const
 
const std::string & get_metadata () const
 A string like "1.0" for Linux RAID, "imsm" or "ddf" for BIOS RAID containers and empty for BIOS RAID members.
 
void set_metadata (const std::string &metadata)
 Currently create always uses metadata 1.0.
 
unsigned int minimal_number_of_devices () const
 Return the minimal number of devices required by the RAID. More...
 
bool is_in_etc_mdadm () const
 Query whether the MD RAID is present (probed devicegraph) or will be present (staging devicegraph) in /etc/mdadm.conf.
 
void set_in_etc_mdadm (bool in_etc_mdadm)
 Set whether the MD RAID will be present in /etc/mdadm.conf.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
virtual Mdclone () const override
 
- Public Member Functions inherited from storage::Partitionable
const Topologyget_topology () const
 
void set_topology (const Topology &topology)
 
unsigned int get_range () const
 
void set_range (unsigned int range)
 
bool is_usable_as_partitionable () const
 Checks whether the partitionable is in general usable as a partitionable (can hold a partition table). More...
 
PtType get_default_partition_table_type () const
 Get the default partition table type for the partitionable. More...
 
std::vector< PtTypeget_possible_partition_table_types () const
 Get possible partition table types for the disk. More...
 
PartitionTablecreate_partition_table (PtType pt_type)
 Create a partition table on the partitionable. More...
 
bool has_partition_table () const
 
PartitionTableget_partition_table ()
 
virtual std::string partition_name (int number) const
 Return the name of the partition with the specified number.
 
const PartitionTableget_partition_table () const
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- Public Member Functions inherited from storage::BlkDevice
const std::string & get_name () const
 
void set_name (const std::string &name)
 
const Regionget_region () const
 
void set_region (const Region &region)
 
unsigned long long get_size () const
 
void set_size (unsigned long long size)
 
std::string get_size_string () const
 
bool is_active () const
 
const std::string & get_sysfs_name () const
 
const std::string & get_sysfs_path () const
 
const std::vector< std::string > & get_udev_paths () const
 
const std::vector< std::string > & get_udev_ids () const
 
bool is_usable_as_blk_device () const
 Checks whether the blk device is in general usable as a blk device. More...
 
const std::string & get_dm_table_name () const
 Return device-mapper table name (dm-table-name for short). More...
 
void set_dm_table_name (const std::string &dm_table_name)
 
BlkFilesystemcreate_blk_filesystem (FsType fs_type)
 Creates a block filesystem on the block device. More...
 
bool has_blk_filesystem () const
 
BlkFilesystemget_blk_filesystem ()
 
const BlkFilesystemget_blk_filesystem () const
 
BlkFilesystemcreate_filesystem (FsType fs_type) ST_DEPRECATED
 Creates a block filesystem on the block device. More...
 
bool has_filesystem () const ST_DEPRECATED
 
BlkFilesystemget_filesystem () ST_DEPRECATED
 
const BlkFilesystemget_filesystem () const ST_DEPRECATED
 
Encryptioncreate_encryption (const std::string &dm_name)
 Creates an encryption device on the blk device. More...
 
void remove_encryption ()
 Removes an encryption device on the blk device. More...
 
bool has_encryption () const
 
Encryptionget_encryption ()
 
const Encryptionget_encryption () const
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
- Public Member Functions inherited from storage::Device
sid_t get_sid () const
 
bool operator== (const Device &rhs) const
 
bool operator!= (const Device &rhs) const
 
Devicecopy_to_devicegraph (Devicegraph *devicegraph) const
 Copies the device to the devicegraph. More...
 
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. More...
 
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_parents ()
 
std::vector< const Device * > get_parents () const
 
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_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 ()
 
const std::map< std::string, std::string > & get_userdata () const
 
void set_userdata (const std::map< std::string, std::string > &userdata)
 
Devicegraphget_devicegraph ()
 
const Devicegraphget_devicegraph () const
 
Impl & get_impl ()
 
const Impl & get_impl () const
 
void save (xmlNode *node) const
 

Static Public Member Functions

static Mdcreate (Devicegraph *devicegraph, const std::string &name)
 Create a MD in devicegraph with name. More...
 
static Mdload (Devicegraph *devicegraph, const xmlNode *node)
 
static std::vector< Md * > get_all (Devicegraph *devicegraph)
 Get all Mds.
 
static std::vector< const Md * > get_all (const Devicegraph *devicegraph)
 Get all Mds. More...
 
static std::vector< Md * > get_all_if (Devicegraph *devicegraph, std::function< bool(const Md *)> pred)
 Get all Mds for which the predicate pred returns true.
 
static std::vector< const Md * > get_all_if (const Devicegraph *devicegraph, std::function< bool(const Md *)> pred)
 Get all Mds for which the predicate pred returns true. More...
 
static Mdfind_by_name (Devicegraph *devicegraph, const std::string &name)
 Find a Md by its name. More...
 
static const Mdfind_by_name (const Devicegraph *devicegraph, const std::string &name)
 Find a Md by its name. More...
 
static std::string find_free_numeric_name (const Devicegraph *devicegraph)
 Find a free numeric name for a MD.
 
static bool compare_by_number (const Md *lhs, const Md *rhs)
 Compare (less than) two Mds by number. More...
 
- Static Public Member Functions inherited from storage::Partitionable
static std::vector< Partitionable * > get_all (Devicegraph *devicegraph)
 Get all Partitionables.
 
static std::vector< const Partitionable * > get_all (const Devicegraph *devicegraph)
 Get all Partitionables. More...
 
static Partitionablefind_by_name (Devicegraph *devicegraph, const std::string &name)
 
static const Partitionablefind_by_name (const Devicegraph *devicegraph, const std::string &name)
 
- Static Public Member Functions inherited from storage::BlkDevice
static std::vector< BlkDevice * > get_all (Devicegraph *devicegraph)
 Get all BlkDevices.
 
static std::vector< const BlkDevice * > get_all (const Devicegraph *devicegraph)
 Get all BlkDevices. More...
 
static BlkDevicefind_by_name (Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name. More...
 
static const BlkDevicefind_by_name (const Devicegraph *devicegraph, const std::string &name)
 Find a block device by its name. More...
 
static BlkDevicefind_by_any_name (Devicegraph *devicegraph, const std::string &name)
 Find a block device by any name including any symbolic links in /dev. More...
 
static const BlkDevicefind_by_any_name (const Devicegraph *devicegraph, const std::string &name)
 Find a block device by any name including any symbolic links in /dev. More...
 
static bool compare_by_dm_table_name (const BlkDevice *lhs, const BlkDevice *rhs)
 Compare (less than) two BlkDevices by DM table name.
 
- Static Public Member Functions inherited from storage::Device
static std::vector< Device * > get_all (Devicegraph *devicegraph)
 
static std::vector< const Device * > get_all (const Devicegraph *devicegraph)
 
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. More...
 

Protected Member Functions

 Md (Impl *impl)
 
- Protected Member Functions inherited from storage::Partitionable
 Partitionable (Impl *impl)
 
- Protected Member Functions inherited from storage::BlkDevice
 BlkDevice (Impl *impl)
 
- Protected Member Functions inherited from storage::Device
 Device (Impl *impl)
 
void create (Devicegraph *devicegraph)
 
void load (Devicegraph *devicegraph)
 

Detailed Description

A MD device.

Member Function Documentation

◆ add_device()

MdUser* storage::Md::add_device ( BlkDevice blk_device)

◆ compare_by_number()

static bool storage::Md::compare_by_number ( const Md lhs,
const Md rhs 
)
static

Compare (less than) two Mds by number.

Exceptions
Exception

◆ create()

static Md* storage::Md::create ( Devicegraph devicegraph,
const std::string &  name 
)
static

Create a MD in devicegraph with name.

Name must either be of the form "/dev/md<number>" or "/dev/md/<name>". The first form is called numeric. If name is a number it is also called numeric.

Exceptions
Exception

◆ find_by_name() [1/2]

static Md* storage::Md::find_by_name ( Devicegraph devicegraph,
const std::string &  name 
)
static

Find a Md by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFound,DeviceHasWrongType

◆ find_by_name() [2/2]

static const Md* storage::Md::find_by_name ( const Devicegraph devicegraph,
const std::string &  name 
)
static

Find a Md by its name.

Only the name returned by get_name() is considered.

Exceptions
DeviceNotFound,DeviceHasWrongType

◆ get_all()

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

Get all Mds.

◆ get_all_if()

static std::vector<const Md*> storage::Md::get_all_if ( const Devicegraph devicegraph,
std::function< bool(const Md *)>  pred 
)
static

Get all Mds for which the predicate pred returns true.

◆ get_allowed_md_parities()

std::vector<MdParity> storage::Md::get_allowed_md_parities ( ) const

Get the allowed parities for the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10. So far depends on the MD RAID level and the number of devices.

Exceptions
Exception

◆ get_md_parity()

MdParity storage::Md::get_md_parity ( ) const

Get the parity of the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10.

◆ get_number()

unsigned int storage::Md::get_number ( ) const

Returns the number of the MD.

Throws if the MD is not numeric.

Exceptions
Exception

◆ minimal_number_of_devices()

unsigned int storage::Md::minimal_number_of_devices ( ) const

Return the minimal number of devices required by the RAID.

For RAIDs of level CONTAINER it returns 0 (those RAIDs cannot be created or modified anyway).

◆ remove_device()

void storage::Md::remove_device ( BlkDevice blk_device)
Exceptions
Exception

◆ set_md_parity()

void storage::Md::set_md_parity ( MdParity  md_parity)

Set the parity of the MD RAID.

Only meaningful for RAID5, RAID6 and RAID10 and for MD RAIDs not created on disk yet.


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