]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/devices/lvm/strategies/strategies.py
2 from ceph_volume
.util
.prepare
import osd_id_available
3 from ceph_volume
.api
.lvm
import get_device_vgs
5 class Strategy(object):
7 def __init__(self
, args
, data_devs
, db_or_journal_devs
=[], wal_devs
=[]):
9 Note that this ctor is used by both bluestore and filestore strategies
10 to reduce code duplication. A filestore strategy will always pass an
11 empty list for wal_devs.
14 self
.osd_ids
= args
.osd_ids
15 self
.osds_per_device
= args
.osds_per_device
16 self
.devices
= data_devs
+ wal_devs
+ db_or_journal_devs
17 self
.data_devs
= data_devs
18 self
.db_or_journal_devs
= db_or_journal_devs
19 self
.wal_devs
= wal_devs
20 self
.computed
= {'osds': [], 'vgs': []}
23 def split_devices_rotational(devices
):
24 data_devs
= [device
for device
in devices
if device
.rotational
]
25 db_or_journal_devs
= [device
for device
in devices
if not device
.rotational
]
26 return data_devs
, db_or_journal_devs
29 def validate_compute(self
):
34 self
.computed
["changed"] = False
36 def report_json(self
, filtered_devices
):
37 # add filtered devices to report
38 report
= self
.computed
.copy()
39 report
['filtered_devices'] = filtered_devices
40 print(json
.dumps(self
.computed
, indent
=4, sort_keys
=True))
42 def _validate_osd_ids(self
):
43 unavailable_ids
= [id_
for id_
in self
.osd_ids
if
44 not osd_id_available(id_
)]
46 msg
= ("Not all specfied OSD ids are available: {}"
47 "unavailable").format(",".join(unavailable_ids
))
48 raise RuntimeError(msg
)
52 return len(self
.data_devs
) * self
.osds_per_device
54 # protect against base class instantiation and incomplete implementations.
55 # We could also use the abc module and implement this as an
58 raise NotImplementedError('compute() must be implemented in a child class')
61 raise NotImplementedError('execute() must be implemented in a child class')
63 class MixedStrategy(Strategy
):
65 def get_common_vg(self
, devs
):
66 # find all the vgs associated with the current device
68 vgs
= get_device_vgs(dev
.abspath
)