libstorage-ng
 All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
Disk.h
1 /*
2  * Copyright (c) [2014-2015] Novell, Inc.
3  * Copyright (c) 2016 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 
31 namespace storage
32 {
33 
35  enum class Transport {
36  UNKNOWN, SBP, ATA, FC, ISCSI, SAS, SATA, SPI, USB, FCOE
37  };
38 
39  std::string get_transport_name(Transport transport);
40 
41 
42  enum DasdFormat {
43  DASDF_NONE, DASDF_LDL, DASDF_CDL
44  };
45 
46 
47  enum DasdType {
48  DASDTYPE_NONE, DASDTYPE_ECKD, DASDTYPE_FBA
49  };
50 
51 
53  class Disk : public Partitionable
54  {
55  public:
56 
57  static Disk* create(Devicegraph* devicegraph, const std::string& name);
58  static Disk* create(Devicegraph* devicegraph, const std::string& name,
59  const Region& region);
60  static Disk* create(Devicegraph* devicegraph, const std::string& name,
61  unsigned long long size);
62 
63  static Disk* load(Devicegraph* devicegraph, const xmlNode* node);
64 
68  static std::vector<Disk*> get_all(Devicegraph* devicegraph);
69 
73  static std::vector<const Disk*> get_all(const Devicegraph* devicegraph);
74 
75  bool get_rotational() const;
76 
77  Transport get_transport() const;
78 
79  static Disk* find_by_name(Devicegraph* devicegraph, const std::string& name);
80  static const Disk* find_by_name(const Devicegraph* devicegraph, const std::string& name);
81 
82  public:
83 
84  class Impl;
85 
86  Impl& get_impl();
87  const Impl& get_impl() const;
88 
89  virtual Disk* clone() const override;
90 
91  protected:
92 
93  Disk(Impl* impl);
94 
95  };
96 
97 
98  bool is_disk(const Device* device);
99 
106  Disk* to_disk(Device* device);
107 
111  const Disk* to_disk(const Device* device);
112 
113 }
114 
115 #endif
A physical disk device.
Definition: Disk.h:53
Disk * to_disk(Device *device)
Converts pointer to Device to pointer to Disk.
A start/length pair with a block size.
Definition: Region.h:71
The master container of the libstorage.
Definition: Devicegraph.h:133
An abstract base class of storage devices, and a vertex in the Devicegraph.
Definition: Device.h:73
Definition: Partitionable.h:40
Transport
Data Transport Layer.
Definition: Disk.h:35
static std::vector< Disk * > get_all(Devicegraph *devicegraph)
Sorted by name.
The storage namespace.
Definition: Actiongraph.h:36