libstorage-ng
Md.h
1 /*
2  * Copyright (c) 2016 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_MD_H
24 #define STORAGE_MD_H
25 
26 
27 #include "storage/Devices/Partitionable.h"
28 
29 
30 namespace storage
31 {
32 
33  class MdUser;
34 
35 
36  enum MdLevel {
37  UNKNOWN, RAID0, RAID1, RAID5, RAID6, RAID10
38  };
39 
40  enum MdParity {
41  DEFAULT, LEFT_ASYMMETRIC, LEFT_SYMMETRIC, RIGHT_ASYMMETRIC,
42  RIGHT_SYMMETRIC, FIRST, LAST, LEFT_ASYMMETRIC_6, LEFT_SYMMETRIC_6,
43  RIGHT_ASYMMETRIC_6, RIGHT_SYMMETRIC_6, FIRST_6, NEAR_2, OFFSET_2,
44  FAR_2, NEAR_3, OFFSET_3, FAR_3
45  };
46 
47 
48  std::string get_md_level_name(MdLevel md_level);
49 
50  std::string get_md_parity_name(MdParity md_parity);
51 
52 
56  class Md : public Partitionable
57  {
58  public:
59 
60  static Md* create(Devicegraph* devicegraph, const std::string& name);
61  static Md* load(Devicegraph* devicegraph, const xmlNode* node);
62 
63  MdUser* add_device(BlkDevice* blk_device);
64  void remove_device(BlkDevice* blk_device);
65 
66  std::vector<BlkDevice*> get_devices();
67  std::vector<const BlkDevice*> get_devices() const;
68 
69  unsigned int get_number() const;
70 
71  MdLevel get_md_level() const;
72  void set_md_level(MdLevel md_level);
73 
74  MdParity get_md_parity() const;
75  void set_md_parity(MdParity md_parity);
76 
77  unsigned long get_chunk_size() const;
78  void set_chunk_size(unsigned long chunk_size);
79 
83  static std::vector<Md*> get_all(Devicegraph* devicegraph);
84 
88  static std::vector<const Md*> get_all(const Devicegraph* devicegraph);
89 
90  static Md* find_by_name(Devicegraph* devicegraph, const std::string& name);
91  static const Md* find_by_name(const Devicegraph* devicegraph, const std::string& name);
92 
93  public:
94 
95  class Impl;
96 
97  Impl& get_impl();
98  const Impl& get_impl() const;
99 
100  virtual Md* clone() const override;
101 
102  protected:
103 
104  Md(Impl* impl);
105 
106  };
107 
108 
109  bool is_md(const Device* device);
110 
117  Md* to_md(Device* device);
118 
122  const Md* to_md(const Device* device);
123 
124 }
125 
126 #endif
static std::vector< Md * > get_all(Devicegraph *devicegraph)
Sorted by number.
A MD device.
Definition: Md.h:56
The master container of the libstorage.
Definition: Devicegraph.h:133
An abstract Block Device.
Definition: BlkDevice.h:40
Definition: MdUser.h:33
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:73
Definition: Partitionable.h:40
The storage namespace.
Definition: Actiongraph.h:36
Md * to_md(Device *device)
Converts pointer to Device to pointer to Md.