libstorage-ng
LvmLv.h
1 /*
2  * Copyright (c) [2016-2017] SUSE LLC
3  *
4  * All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, contact Novell, Inc.
17  *
18  * To contact Novell about this file by physical or electronic mail, you may
19  * find current contact information at www.novell.com.
20  */
21 
22 
23 #ifndef STORAGE_LVM_LV_H
24 #define STORAGE_LVM_LV_H
25 
26 
27 #include "storage/Devices/BlkDevice.h"
28 #include "storage/Devicegraph.h"
29 
30 
31 namespace storage
32 {
33 
34  class LvmVg;
35 
36 
40  enum class LvType
41  {
42  UNKNOWN, NORMAL, THIN_POOL, THIN, RAID
43  };
44 
45 
47  {
48  public:
49 
50  LvmLvNotFoundByLvName(const std::string& lv_name);
51  };
52 
53 
57  class LvmLv : public BlkDevice
58  {
59 
60  public:
61 
62  static LvmLv* create(Devicegraph* devicegraph, const std::string& vg_name,
63  const std::string& lv_name, LvType lv_type);
64  static LvmLv* load(Devicegraph* devicegraph, const xmlNode* node);
65 
69  static std::vector<LvmLv*> get_all(Devicegraph* devicegraph);
70 
74  static std::vector<const LvmLv*> get_all(const Devicegraph* devicegraph);
75 
79  const std::string& get_lv_name() const;
80  void set_lv_name(const std::string& lv_name);
81 
82  LvType get_lv_type() const;
83 
84  unsigned int get_stripes() const;
85 
93  void set_stripes(unsigned int stripes);
94 
95  unsigned long long get_stripe_size() const;
96 
100  void set_stripe_size(unsigned long long stripe_size);
101 
102  unsigned long long get_chunk_size() const;
103 
109  void set_chunk_size(unsigned long long chunk_size);
110 
116  const LvmVg* get_lvm_vg() const;
117 
123  const LvmLv* get_thin_pool() const;
124 
133  unsigned long long max_size_for_lvm_lv(LvType lv_type) const;
134 
141  LvmLv* create_lvm_lv(const std::string& lv_name, LvType lv_type, unsigned long long size);
142 
146  LvmLv* get_lvm_lv(const std::string& lv_name);
147 
148  std::vector<LvmLv*> get_lvm_lvs();
149  std::vector<const LvmLv*> get_lvm_lvs() const;
150 
154  static bool compare_by_lv_name(const LvmLv* lhs, const LvmLv* rhs);
155 
156  public:
157 
158  class Impl;
159 
160  Impl& get_impl();
161  const Impl& get_impl() const;
162 
163  virtual LvmLv* clone() const override;
164 
165  protected:
166 
167  LvmLv(Impl* impl);
168 
169  };
170 
171 
172  bool is_lvm_lv(const Device* device);
173 
180  LvmLv* to_lvm_lv(Device* device);
181 
185  const LvmLv* to_lvm_lv(const Device* device);
186 
187 }
188 
189 #endif
A Logical Volume of the Logical Volume Manager (LVM).
Definition: LvmLv.h:57
static bool compare_by_lv_name(const LvmLv *lhs, const LvmLv *rhs)
Compare (less than) two LvmLvs by lv-name.
const LvmVg * get_lvm_vg() const
Return volume group this logical volume belongs to.
LvmLv * get_lvm_lv(const std::string &lv_name)
const std::string & get_lv_name() const
Get logical volume name.
A Volume Group of the Logical Volume Manager (LVM).
Definition: LvmVg.h:59
Definition: LvmLv.h:46
LvmLv * 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 thin pool.
const LvmLv * get_thin_pool() const
Return the thin pool for a thin logical volume.
The master container of the libstorage.
Definition: Devicegraph.h:153
An abstract Block Device.
Definition: BlkDevice.h:41
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.
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:75
Definition: Devicegraph.h:48
void set_chunk_size(unsigned long long chunk_size)
Set the chunk size.
The storage namespace.
Definition: Actiongraph.h:37
LvType
LVM logical volume types, see lvs(8).
Definition: LvmLv.h:40
static std::vector< LvmLv * > get_all(Devicegraph *devicegraph)
Get all LvmLvs.
void set_stripes(unsigned int stripes)
Set the number of stripes.
LvmLv * to_lvm_lv(Device *device)
Converts pointer to Device to pointer to LvmLv.
void set_stripe_size(unsigned long long stripe_size)