libstorage-ng
Loading...
Searching...
No Matches
Disk.h
1/*
2 * Copyright (c) [2014-2015] Novell, Inc.
3 * Copyright (c) [2016-2023] SUSE LLC
4 *
5 * All Rights Reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as published
9 * by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, contact Novell, Inc.
18 *
19 * To contact Novell about this file by physical or electronic mail, you may
20 * find current contact information at www.novell.com.
21 */
22
23
24#ifndef STORAGE_DISK_H
25#define STORAGE_DISK_H
26
27
28#include "storage/Devices/Partitionable.h"
29
30
31namespace storage
32{
33
37 enum class Transport {
38 UNKNOWN, SBP, ATA, FC, ISCSI, SAS, SATA, SPI, USB, FCOE, PCIE, TCP, RDMA, LOOP
39 };
40
41
47 std::string get_transport_name(Transport transport);
48
49
56 enum class ZoneModel {
57 NONE, HOST_AWARE, HOST_MANAGED
58 };
59
60
66 std::string get_zone_model_name(ZoneModel zone_model);
67
68
72 class Disk : public Partitionable
73 {
74 public:
75
82 static Disk* create(Devicegraph* devicegraph, const std::string& name);
83
87 static Disk* create(Devicegraph* devicegraph, const std::string& name,
88 const Region& region);
89
93 static Disk* create(Devicegraph* devicegraph, const std::string& name,
94 unsigned long long size);
95
96 static Disk* load(Devicegraph* devicegraph, const xmlNode* node);
97
101 static std::vector<Disk*> get_all(Devicegraph* devicegraph);
102
106 static std::vector<const Disk*> get_all(const Devicegraph* devicegraph);
107
113 bool is_rotational() const;
114
119 bool is_dax() const;
120
125
132
136 bool is_pmem() const;
137
141 bool is_nvme() const;
142
146 const std::string& get_image_filename() const;
147
152 void set_image_filename(const std::string& image_filename);
153
160 static Disk* find_by_name(Devicegraph* devicegraph, const std::string& name);
161
165 static const Disk* find_by_name(const Devicegraph* devicegraph, const std::string& name);
166
167 public:
168
169 class Impl;
170
171 Impl& get_impl();
172 const Impl& get_impl() const;
173
174 virtual Disk* clone() const override;
175
176 Disk(Impl* impl);
177
178 };
179
180
186 bool is_disk(const Device* device);
187
194 Disk* to_disk(Device* device);
195
199 const Disk* to_disk(const Device* device);
200
201}
202
203#endif
An abstract base class for storage devices.
Definition Device.h:82
The main container of the libstorage-ng.
Definition Devicegraph.h:170
A physical disk device.
Definition Disk.h:73
void set_image_filename(const std::string &image_filename)
Set the filename for the underlying image.
static Disk * find_by_name(Devicegraph *devicegraph, const std::string &name)
Find a Disk by its name.
const std::string & get_image_filename() const
Get the filename for the underlying image.
static std::vector< Disk * > get_all(Devicegraph *devicegraph)
Get all Disks.
static Disk * create(Devicegraph *devicegraph, const std::string &name, const Region &region)
Create a device of type Disk.
static Disk * create(Devicegraph *devicegraph, const std::string &name, unsigned long long size)
Create a device of type Disk.
static Disk * create(Devicegraph *devicegraph, const std::string &name)
Create a device of type Disk.
bool is_nvme() const
Return whether the disk is an NVMe device.
bool is_rotational() const
Return whether the disk is of rotational or non-rotational type.
ZoneModel get_zone_model() const
Get the zone model of the disk.
static const Disk * find_by_name(const Devicegraph *devicegraph, const std::string &name)
Find a Disk by its name.
static std::vector< const Disk * > get_all(const Devicegraph *devicegraph)
Get all Disks.
bool is_dax() const
Return whether the disk supports Direct Access (DAX).
bool is_pmem() const
Return whether the disk is an PMEM device.
Transport get_transport() const
Get the transport of the disk.
Definition Partitionable.h:40
A start/length pair with a block size.
Definition Region.h:85
The storage namespace.
Definition Actiongraph.h:40
bool is_disk(const Device *device)
Checks whether device points to a Disk.
Transport
Data Transport Layer.
Definition Disk.h:37
std::string get_transport_name(Transport transport)
Convert the Transport transport to a string.
ZoneModel
Zone model as read from /sys.
Definition Disk.h:56
Disk * to_disk(Device *device)
Converts pointer to Device to pointer to Disk.
std::string get_zone_model_name(ZoneModel zone_model)
Convert the ZoneModel zone_model to a string.