libstorage-ng
Multipath.h
1 /*
2  * Copyright (c) [2017-2021] 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_MULTIPATH_H
24 #define STORAGE_MULTIPATH_H
25 
26 
27 #include "storage/Devices/Partitionable.h"
28 
29 
30 namespace storage
31 {
32 
33 
37  class Multipath : public Partitionable
38  {
39  public:
40 
47  static Multipath* create(Devicegraph* devicegraph, const std::string& name);
48 
52  static Multipath* create(Devicegraph* devicegraph, const std::string& name,
53  const Region& region);
54 
58  static Multipath* create(Devicegraph* devicegraph, const std::string& name,
59  unsigned long long size);
60 
61  static Multipath* load(Devicegraph* devicegraph, const xmlNode* node);
62 
66  static std::vector<Multipath*> get_all(Devicegraph* devicegraph);
67 
71  static std::vector<const Multipath*> get_all(const Devicegraph* devicegraph);
72 
78  const std::string& get_vendor() const;
79 
85  const std::string& get_model() const;
86 
90  std::vector<BlkDevice*> get_blk_devices();
91 
95  std::vector<const BlkDevice*> get_blk_devices() const;
96 
102  bool is_rotational() const;
103 
110  static Multipath* find_by_name(Devicegraph* devicegraph, const std::string& name);
111 
115  static const Multipath* find_by_name(const Devicegraph* devicegraph, const std::string& name);
116 
117  public:
118 
119  class Impl;
120 
121  Impl& get_impl();
122  const Impl& get_impl() const;
123 
124  virtual Multipath* clone() const override;
125 
126  protected:
127 
128  Multipath(Impl* impl);
129 
130  };
131 
132 
138  bool is_multipath(const Device* device);
139 
146  Multipath* to_multipath(Device* device);
147 
151  const Multipath* to_multipath(const Device* device);
152 
153 }
154 
155 #endif
const std::string & get_model() const
The model as reported by multipath tools.
Multipath * to_multipath(Device *device)
Converts pointer to Device to pointer to Multipath.
A start/length pair with a block size.
Definition: Region.h:84
static Multipath * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a Multipath by its name.
const std::string & get_vendor() const
The vendor as reported by multipath tools.
The main container of the libstorage-ng.
Definition: Devicegraph.h:169
static Multipath * create(Devicegraph *devicegraph, const std::string &name)
Create a device of type Multipath.
A multipath device.
Definition: Multipath.h:37
An abstract base class for storage devices.
Definition: Device.h:81
Definition: Partitionable.h:39
std::vector< BlkDevice * > get_blk_devices()
Return blk devices used for the Multipath.
static std::vector< Multipath * > get_all(Devicegraph *devicegraph)
Get all Multipaths.
bool is_multipath(const Device *device)
Checks whether device points to a Multipath.
The storage namespace.
Definition: Actiongraph.h:38
bool is_rotational() const
Return whether the multipath device is of rotational or non-rotational type.