]>
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
4 class Strategy(object):
6 def __init__(self
, args
, data_devs
, db_or_journal_devs
=[], wal_devs
=[]):
8 Note that this ctor is used by both bluestore and filestore strategies
9 to reduce code duplication. A filestore strategy will always pass an
10 empty list for wal_devs.
13 self
.osd_ids
= args
.osd_ids
14 self
.osds_per_device
= args
.osds_per_device
15 self
.devices
= data_devs
+ wal_devs
+ db_or_journal_devs
16 self
.data_devs
= data_devs
17 self
.db_or_journal_devs
= db_or_journal_devs
18 self
.wal_devs
= wal_devs
19 self
.computed
= {'osds': [], 'vgs': []}
22 def split_devices_rotational(devices
):
23 data_devs
= [device
for device
in devices
if device
.sys_api
['rotational'] == '1']
24 db_or_journal_devs
= [device
for device
in devices
if device
.sys_api
['rotational'] == '0']
25 return data_devs
, db_or_journal_devs
28 def validate_compute(self
):
33 self
.computed
["changed"] = False
35 def report_json(self
, filtered_devices
):
36 # add filtered devices to report
37 report
= self
.computed
.copy()
38 report
['filtered_devices'] = filtered_devices
39 print(json
.dumps(self
.computed
, indent
=4, sort_keys
=True))
41 def _validate_osd_ids(self
):
42 unavailable_ids
= [id_
for id_
in self
.osd_ids
if
43 not osd_id_available(id_
)]
45 msg
= ("Not all specfied OSD ids are available: {}"
46 "unavailable").format(",".join(unavailable_ids
))
47 raise RuntimeError(msg
)
51 return len(self
.data_devs
) * self
.osds_per_device
53 # protect against base class instantiation and incomplete implementations.
54 # We could also use the abc module and implement this as an
57 raise NotImplementedError('compute() must be implemented in a child class')
60 raise NotImplementedError('execute() must be implemented in a child class')
62 class MixedStrategy(Strategy
):
64 def get_common_vg(self
, devs
):
65 # find all the vgs associated with the current device
67 for pv
in dev
.pvs_api
:
68 vg
= self
.system_vgs
.get(vg_name
=pv
.vg_name
)
71 # this should give us just one VG, it would've been caught by
72 # the validator otherwise