libstorage-ng
 
Loading...
Searching...
No Matches
storage::Devicegraph Class Reference

The main container of the libstorage-ng. More...

#include <Devicegraph.h>

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

Public Member Functions

 Devicegraph (Storage *storage)
 
bool operator== (const Devicegraph &rhs) const
 
bool operator!= (const Devicegraph &rhs) const
 
Storageget_storage ()
 Get the storage object the devicegraph belongs to.
 
const Storageget_storage () const
 Get the storage object the devicegraph belongs to.
 
void load (const std::string &filename)
 Load the devicegraph from a file.
 
void load (const std::string &filename, bool keep_sids)
 Load the devicegraph from a file.
 
void save (const std::string &filename) const
 Save the devicegraph to a file.
 
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.
 
Devicefind_device (sid_t sid)
 
const Devicefind_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.
 
std::vector< Disk * > get_all_disks ()
 Get all Disks.
 
std::vector< const Disk * > get_all_disks () const
 Get all Disks.
 
std::vector< Md * > get_all_mds ()
 Get all Mds.
 
std::vector< const Md * > get_all_mds () const
 Get all Mds.
 
std::vector< LvmVg * > get_all_lvm_vgs ()
 Get all LvmVgs.
 
std::vector< const LvmVg * > get_all_lvm_vgs () const
 Get all LvmVgs.
 
std::vector< Filesystem * > get_all_filesystems ()
 Get all Filesystems.
 
std::vector< const Filesystem * > get_all_filesystems () const
 Get all Filesystems.
 
std::vector< BlkFilesystem * > get_all_blk_filesystems ()
 Get all BlkFilesystems.
 
std::vector< const BlkFilesystem * > get_all_blk_filesystems () const
 Get all BlkFilesystems.
 
void remove_device (sid_t sid)
 Removes the device with sid from the devicegraph.
 
void remove_device (Device *a)
 Removes the device from the devicegraph.
 
void remove_devices (std::vector< Device * > devices)
 Removes the devices from the devicegraph.
 
Holderfind_holder (sid_t source_sid, sid_t target_sid)
 Find the holder with source_sid and target_sid.
 
const Holderfind_holder (sid_t source_sid, sid_t target_sid) const
 Find the holder with source_sid and target_sid.
 
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.
 
void remove_holder (Holder *holder)
 Removes the holder from the devicegraph.
 
void check (const CheckCallbacks *check_callbacks=nullptr) const
 Checks the devicegraph.
 
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.
 
void write_graphviz (const std::string &filename, DevicegraphStyleCallbacks *style_callbacks) const ST_DEPRECATED
 Writes the devicegraph in graphviz format.
 
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.
 
Impl & get_impl ()
 
const Impl & get_impl () const
 

Friends

std::ostream & operator<< (std::ostream &out, const Devicegraph &devicegraph)
 

Detailed Description

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.

Whenever possible use the high-level functions.

Member Function Documentation

◆ check()

void storage::Devicegraph::check ( const CheckCallbacks * check_callbacks = nullptr) const

Checks the devicegraph.

See also Storage::check().

Exceptions
Exception

◆ clear()

void storage::Devicegraph::clear ( )

Clear the devicegraph.

Invalidates all pointers to devices and holders of the devicegraph.

◆ find_device() [1/2]

Device * storage::Devicegraph::find_device ( sid_t sid)
Exceptions
DeviceNotFoundBySid

◆ find_device() [2/2]

const Device * storage::Devicegraph::find_device ( sid_t sid) const
Exceptions
DeviceNotFoundBySid

◆ find_holder() [1/2]

Holder * storage::Devicegraph::find_holder ( sid_t source_sid,
sid_t target_sid )

Find the holder with source_sid and target_sid.

Fails if there is not exactly one holder.

Exceptions
HolderNotFoundBySids,WrongNumberOfHolders

◆ find_holder() [2/2]

const Holder * storage::Devicegraph::find_holder ( sid_t source_sid,
sid_t target_sid ) const

Find the holder with source_sid and target_sid.

Fails if there is not exactly one holder.

Exceptions
HolderNotFoundBySids,WrongNumberOfHolders

◆ find_holders()

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.

◆ get_all_blk_filesystems() [1/2]

std::vector< BlkFilesystem * > storage::Devicegraph::get_all_blk_filesystems ( )

Get all BlkFilesystems.

Convenience functions, equivalent to BlkFilesystem::get_all(devicegraph).

See also
BlkFilesystem::get_all()

◆ get_all_blk_filesystems() [2/2]

std::vector< const BlkFilesystem * > storage::Devicegraph::get_all_blk_filesystems ( ) const

Get all BlkFilesystems.

Convenience functions, equivalent to BlkFilesystem::get_all(devicegraph).

See also
BlkFilesystem::get_all()

◆ get_all_disks() [1/2]

std::vector< Disk * > storage::Devicegraph::get_all_disks ( )

Get all Disks.

Convenience functions, equivalent to Disk::get_all(devicegraph).

See also
Disk::get_all()

◆ get_all_disks() [2/2]

std::vector< const Disk * > storage::Devicegraph::get_all_disks ( ) const

Get all Disks.

Convenience functions, equivalent to Disk::get_all(devicegraph).

See also
Disk::get_all()

◆ get_all_filesystems() [1/2]

std::vector< Filesystem * > storage::Devicegraph::get_all_filesystems ( )

Get all Filesystems.

Convenience functions, equivalent to Filesystem::get_all(devicegraph).

See also
Filesystem::get_all()

◆ get_all_filesystems() [2/2]

std::vector< const Filesystem * > storage::Devicegraph::get_all_filesystems ( ) const

Get all Filesystems.

Convenience functions, equivalent to Filesystem::get_all(devicegraph).

See also
Filesystem::get_all()

◆ get_all_lvm_vgs() [1/2]

std::vector< LvmVg * > storage::Devicegraph::get_all_lvm_vgs ( )

Get all LvmVgs.

Convenience functions, equivalent to LvmVg::get_all(devicegraph).

See also
LvmVg::get_all()

◆ get_all_lvm_vgs() [2/2]

std::vector< const LvmVg * > storage::Devicegraph::get_all_lvm_vgs ( ) const

Get all LvmVgs.

Convenience functions, equivalent to LvmVg::get_all(devicegraph).

See also
LvmVg::get_all()

◆ get_all_mds() [1/2]

std::vector< Md * > storage::Devicegraph::get_all_mds ( )

Get all Mds.

Convenience functions, equivalent to Md::get_all(devicegraph).

See also
Md::get_all()

◆ get_all_mds() [2/2]

std::vector< const Md * > storage::Devicegraph::get_all_mds ( ) const

Get all Mds.

Convenience functions, equivalent to Md::get_all(devicegraph).

See also
Md::get_all()

◆ get_storage()

const Storage * storage::Devicegraph::get_storage ( ) const

Get the storage object the devicegraph belongs to.

◆ load() [1/2]

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.

Exceptions
Exception

◆ load() [2/2]

void storage::Devicegraph::load ( const std::string & filename,
bool keep_sids )

Load the devicegraph from a file.

Exceptions
Exception

◆ remove_device() [1/2]

void storage::Devicegraph::remove_device ( Device * a)

Removes the device from the devicegraph.

See also
remove_device(sid_t)

◆ remove_device() [2/2]

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?

Exceptions
DeviceNotFoundBySid

◆ remove_devices()

void storage::Devicegraph::remove_devices ( std::vector< Device * > devices)

Removes the devices from the devicegraph.

See also
remove_device(Device*)

◆ remove_holder()

void storage::Devicegraph::remove_holder ( Holder * holder)

Removes the holder from the devicegraph.

Invalidates all pointers to the holder.

◆ save()

void storage::Devicegraph::save ( const std::string & filename) const

Save the devicegraph to a file.

Exceptions
Exception

◆ write_graphviz() [1/3]

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.

Exceptions
Exception

◆ write_graphviz() [2/3]

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.

Exceptions
Exception

◆ write_graphviz() [3/3]

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).

Exceptions
Exception

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