]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/devices/lvm/strategies/validators.py
1 from ceph_volume
.util
import disk
2 from ceph_volume
.api
import lvm
5 def minimum_device_size(devices
):
7 Ensure that the minimum requirements for this type of scenario is
8 met, raise an error if the provided devices would not work
10 msg
= 'Unable to use device smaller than 5GB: %s (%s)'
11 for device
in devices
:
12 device_size
= disk
.Size(b
=device
.sys_api
['size'])
13 if device_size
< disk
.Size(gb
=5):
14 raise RuntimeError(msg
% (device
, device_size
))
17 def no_lvm_membership(devices
):
19 Do not allow devices that are part of LVM
21 msg
= 'Unable to use device, already a member of LVM: %s'
22 for device
in devices
:
23 if device
.is_lvm_member
:
24 raise RuntimeError(msg
% device
.abspath
)
27 def has_common_vg(ssd_devices
):
29 Ensure that devices have a common VG between them
31 msg
= 'Could not find a common VG between devices: %s'
32 system_vgs
= lvm
.VolumeGroups()
35 for ssd_device
in ssd_devices
:
36 for pv
in ssd_device
.pvs_api
:
37 vg
= system_vgs
.get(vg_name
=pv
.vg_name
)
41 ssd_vgs
[vg
.name
].append(ssd_device
.abspath
)
43 ssd_vgs
[vg
.name
] = [ssd_device
.abspath
]
44 # len of 1 means they all have a common vg, and len of 0 means that these
48 raise RuntimeError(msg
% ', '.join(ssd_vgs
.keys()))