libstorage-ng
|
The main container of the libstorage-ng. More...
#include <Devicegraph.h>
Public Member Functions | |
Devicegraph (Storage *storage) | |
bool | operator== (const Devicegraph &rhs) const |
bool | operator!= (const Devicegraph &rhs) const |
Storage * | get_storage () |
Get the storage object the devicegraph belongs to. | |
const Storage * | get_storage () const |
Get the storage object the devicegraph belongs to. More... | |
void | load (const std::string &filename) |
Load the devicegraph from a file. More... | |
void | load (const std::string &filename, bool keep_sids) |
Load the devicegraph from a file. More... | |
void | save (const std::string &filename) const |
Save the devicegraph to a file. More... | |
bool | empty () const |
Query whether the devicegraph is empty. | |
size_t | num_devices () const |
Return the number of devices. | |
size_t | num_holders () const |
Return the number of holders. | |
Device * | find_device (sid_t sid) |
const Device * | find_device (sid_t sid) const |
bool | device_exists (sid_t sid) const |
Check whether the device with sid exists. | |
bool | holder_exists (sid_t source_sid, sid_t target_sid) const |
Check whether a holder with source_sid and target_sid exists. | |
void | clear () |
Clear the devicegraph. More... | |
std::vector< Disk * > | get_all_disks () |
Get all Disks. More... | |
std::vector< const Disk * > | get_all_disks () const |
Get all Disks. More... | |
std::vector< Md * > | get_all_mds () |
Get all Mds. More... | |
std::vector< const Md * > | get_all_mds () const |
Get all Mds. More... | |
std::vector< LvmVg * > | get_all_lvm_vgs () |
Get all LvmVgs. More... | |
std::vector< const LvmVg * > | get_all_lvm_vgs () const |
Get all LvmVgs. More... | |
std::vector< Filesystem * > | get_all_filesystems () |
Get all Filesystems. More... | |
std::vector< const Filesystem * > | get_all_filesystems () const |
Get all Filesystems. More... | |
std::vector< BlkFilesystem * > | get_all_blk_filesystems () |
Get all BlkFilesystems. More... | |
std::vector< const BlkFilesystem * > | get_all_blk_filesystems () const |
Get all BlkFilesystems. More... | |
void | remove_device (sid_t sid) |
Removes the device with sid from the devicegraph. More... | |
void | remove_device (Device *a) |
Removes the device from the devicegraph. More... | |
void | remove_devices (std::vector< Device *> devices) |
Removes the devices from the devicegraph. More... | |
Holder * | find_holder (sid_t source_sid, sid_t target_sid) |
Find the holder with source_sid and target_sid. More... | |
const Holder * | find_holder (sid_t source_sid, sid_t target_sid) const |
Find the holder with source_sid and target_sid. More... | |
std::vector< Holder * > | find_holders (sid_t source_sid, sid_t target_sid) |
Find all holders with source_sid and sid_t target_sid. | |
std::vector< const Holder * > | find_holders (sid_t source_sid, sid_t target_sid) const |
Find all holders with source_sid and sid_t target_sid. More... | |
void | remove_holder (Holder *holder) |
Removes the holder from the devicegraph. More... | |
void | check (const CheckCallbacks *check_callbacks=nullptr) const |
Checks the devicegraph. More... | |
uint64_t | used_features () const ST_DEPRECATED |
uf_t | used_features (UsedFeaturesDependencyType used_features_dependency_type) const |
Calculates a bit-field with the used features of the devicegraph. | |
void | copy (Devicegraph &dest) const |
void | write_graphviz (const std::string &filename, DevicegraphStyleCallbacks *style_callbacks, View view) const |
Writes the devicegraph in graphviz format. More... | |
void | write_graphviz (const std::string &filename, DevicegraphStyleCallbacks *style_callbacks) const ST_DEPRECATED |
Writes the devicegraph in graphviz format. More... | |
void | write_graphviz (const std::string &filename, GraphvizFlags flags=GraphvizFlags::NAME, GraphvizFlags tooltip_flags=GraphvizFlags::NONE) const ST_DEPRECATED |
Writes the devicegraph in graphviz format. More... | |
Impl & | get_impl () |
const Impl & | get_impl () const |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Devicegraph &devicegraph) |
The main container of the libstorage-ng.
The devicegraph contains Devices (node) and Holders (edge). A device represent a storage object, e.g. a disk, a LVM volume group, a file systems or a mount point. A holder represent the connection between two devices, e.g. that a disk is used by a file system or that a partition is used as a LVM physical volume.
There are two levels of functions to manipulate the device graph. As an example we show how to create a partition table containing one partition on the disk sda.
These functions will not only create the Gpt and Partition object but also the holders in the device graph.
As you can see with the low-level functions you have to create the holders yourself.
Whenever possible use the high-level functions.
void storage::Devicegraph::check | ( | const CheckCallbacks * | check_callbacks = nullptr | ) | const |
void storage::Devicegraph::clear | ( | ) |
Clear the devicegraph.
Invalidates all pointers to devices and holders of the devicegraph.
DeviceNotFoundBySid |
DeviceNotFoundBySid |
Find the holder with source_sid and target_sid.
Fails if there is not exactly one holder.
HolderNotFoundBySids,WrongNumberOfHolders |
Find the holder with source_sid and target_sid.
Fails if there is not exactly one holder.
HolderNotFoundBySids,WrongNumberOfHolders |
std::vector<const Holder*> storage::Devicegraph::find_holders | ( | sid_t | source_sid, |
sid_t | target_sid | ||
) | const |
Find all holders with source_sid and sid_t target_sid.
std::vector<BlkFilesystem*> storage::Devicegraph::get_all_blk_filesystems | ( | ) |
Get all BlkFilesystems.
Convenience functions, equivalent to BlkFilesystem::get_all(devicegraph).
std::vector<const BlkFilesystem*> storage::Devicegraph::get_all_blk_filesystems | ( | ) | const |
Get all BlkFilesystems.
Convenience functions, equivalent to BlkFilesystem::get_all(devicegraph).
std::vector<Disk*> storage::Devicegraph::get_all_disks | ( | ) |
Get all Disks.
Convenience functions, equivalent to Disk::get_all(devicegraph).
std::vector<const Disk*> storage::Devicegraph::get_all_disks | ( | ) | const |
Get all Disks.
Convenience functions, equivalent to Disk::get_all(devicegraph).
std::vector<Filesystem*> storage::Devicegraph::get_all_filesystems | ( | ) |
Get all Filesystems.
Convenience functions, equivalent to Filesystem::get_all(devicegraph).
std::vector<const Filesystem*> storage::Devicegraph::get_all_filesystems | ( | ) | const |
Get all Filesystems.
Convenience functions, equivalent to Filesystem::get_all(devicegraph).
std::vector<LvmVg*> storage::Devicegraph::get_all_lvm_vgs | ( | ) |
Get all LvmVgs.
Convenience functions, equivalent to LvmVg::get_all(devicegraph).
std::vector<const LvmVg*> storage::Devicegraph::get_all_lvm_vgs | ( | ) | const |
Get all LvmVgs.
Convenience functions, equivalent to LvmVg::get_all(devicegraph).
std::vector<Md*> storage::Devicegraph::get_all_mds | ( | ) |
std::vector<const Md*> storage::Devicegraph::get_all_mds | ( | ) | const |
const Storage* storage::Devicegraph::get_storage | ( | ) | const |
Get the storage object the devicegraph belongs to.
void storage::Devicegraph::load | ( | const std::string & | filename | ) |
Load the devicegraph from a file.
Deprecated in favor of load(const std::string&, bool keep_sids) which will get the default of true for keep_sids.
Exception |
void storage::Devicegraph::load | ( | const std::string & | filename, |
bool | keep_sids | ||
) |
Load the devicegraph from a file.
Exception |
void storage::Devicegraph::remove_device | ( | sid_t | sid | ) |
Removes the device with sid from the devicegraph.
Only use this function if there is no special function to delete a device, e.g. PartitionTable.delete_partition() or LvmVg.delete_lvm_lv().
Invalidates all pointers to the device and its holders.
TODO internally redirect to special delete functions?
DeviceNotFoundBySid |
void storage::Devicegraph::remove_device | ( | Device * | a | ) |
Removes the device from the devicegraph.
void storage::Devicegraph::remove_devices | ( | std::vector< Device *> | devices | ) |
Removes the devices from the devicegraph.
void storage::Devicegraph::remove_holder | ( | Holder * | holder | ) |
Removes the holder from the devicegraph.
Invalidates all pointers to the holder.
void storage::Devicegraph::save | ( | const std::string & | filename | ) | const |
Save the devicegraph to a file.
Exception |
void storage::Devicegraph::write_graphviz | ( | const std::string & | filename, |
DevicegraphStyleCallbacks * | style_callbacks, | ||
View | view | ||
) | const |
Writes the devicegraph in graphviz format.
The node id is the sid (storage id). The style_callbacks are used to define graphviz attributes for the graph, nodes and edges, e.g. label, color and shape.
Exception |
void storage::Devicegraph::write_graphviz | ( | const std::string & | filename, |
DevicegraphStyleCallbacks * | style_callbacks | ||
) | const |
Writes the devicegraph in graphviz format.
The node id is the sid (storage id). The style_callbacks are used to define graphviz attributes for the graph, nodes and edges, e.g. label, color and shape.
Exception |
void storage::Devicegraph::write_graphviz | ( | const std::string & | filename, |
GraphvizFlags | flags = GraphvizFlags::NAME , |
||
GraphvizFlags | tooltip_flags = GraphvizFlags::NONE |
||
) | const |
Writes the devicegraph in graphviz format.
The node id is the sid (storage id).
Deprecated in favor of write_graphviz(const std::string&, DevicegraphStyleCallbacks*, View).
Exception |