This new ceph-disk workunit re-implements the tests that previously were
in the src/test/ceph-disk.sh src/test/ceph-disk-root.sh scripts and is
meant to run in a virtual machine instead of docker.
Signed-off-by: Loic Dachary <ldachary@redhat.com>
The ceph-disk list command is reworked in two parts:
1) the list_devices function that build an internal structure with all
the information regarding disks and partitions.
2) a function to display the internal structure in plain text or json
The ceph-disk list show the plain text version and is backward
compatible.
The ceph-disk list --format json output has more information about each
device than the plain text version and is intended for scripts.
The unit tests cover all modified lines (2610 to 2849).
Signed-off-by: Loic Dachary <ldachary@redhat.com>
Make parse_args and main use and argument instead of relying on
argparse.ArgumentParser implicit use of sys.argv. It helps with tests.
Signed-off-by: Loic Dachary <ldachary@redhat.com>
They were designed to run in a docker container using loop devices
instead of disks. Although this was fit for ceph-disk activate tests for
regular and dmcrypt devices, a docker instance does not have its own
udev instance it is not possible to run tests involving udev events
without interfering with the host.
Signed-off-by: Loic Dachary <ldachary@redhat.com>
A multipath device is detected because there is a
/sys/dev/block/M:m/dm/uuid file with the mpath- prefix (or part\w+-mpath
prefix).
When ceph-disk prepares data or journal devices on a multipath device,
it sets the partition typecode to MPATH_JOURNAL_UUID, MPATH_OSD_UUID and
MPATH_TOBE_UUID to
a) help the udev rules distinguish them from other devices in
devicemapper
b) allow ceph-disk to fail if an attempt is made to activate a device
with this type without accessing it via a multipath device
The 95-ceph-osd.rules call ceph-disk activate on partitions of type
MPATH_JOURNAL_UUID, MPATH_OSD_UUID. It relies on ceph-disk to do nothing
if the device is not accessed via multipath.
http://tracker.ceph.com/issues/11881Fixes: #11881
Signed-off-by: Loic Dachary <ldachary@redhat.com>
Always return an empty list when is_held is called on a multipath
device.
The dmcrypt logic base decisions depending on the holders/slaves
relationship. Such relationships can also exists for multipath devices
but do not have the same semantic.
http://tracker.ceph.com/issues/11881Fixes: #11881
Signed-off-by: Loic Dachary <ldachary@redhat.com>
Mimic the get_partition_type implementation after get_partition_uuid
and factorize them to reduce the code footprint.
The get_partition_type implementation is based on blkid: it is complex
and fragile. Since sgdisk is consistently used to create partitions, use
it instead. It is already used for get_partition_uuid and there does not
seem to be any reason for concern.
http://tracker.ceph.com/issues/11881 Refs: #11881
Signed-off-by: Loic Dachary <ldachary@redhat.com>
split_dev_base_partnum returns the path of the whole disk in
/dev/mapper. The base variable name to designate the device for the
whole disk is a misnomer since it cannot be used as a basename to
rebuild the parition device name in the case of multipath.
The logic of split_dev_base_partnum for devices is reworked to use
/sys/dev/block/M:m/partition instead of device name parsing.
http://tracker.ceph.com/issues/11881 Refs: #11881
Signed-off-by: Loic Dachary <ldachary@redhat.com>
The is_partition predicate and the list_partitions function support
devices managed by multipath.
A set of helpers dedicated to multipath devices is implemented because
the content of the corresponding /sys directory does not use the same
conventions as regular devices regarding partitions.
Instead of relying on subdirectories such as /sys/block/name/name1, the
devicemapper uuid file is used and expected to start with part\d+. The
holders/slaves directories provide pointers between the whole device and
the partition devices.
Although these structural differences reduce the opportunity for
code factorization, it is easier for backward compatibility since the
multipath specific logic is limited to if is_mpath(dev) branches.
http://tracker.ceph.com/issues/11881 Refs: #11881
Signed-off-by: Loic Dachary <ldachary@redhat.com>
When running with --verbose, do not hide the stack trace from the user
when an exception is raised. It is most helpful to figure out when the
exception actually happened.
Signed-off-by: Loic Dachary <ldachary@redhat.com>
Older distributions that required partx (CentOS 6 and the like) are no
longer supported and the partx fallback can be obsoleted.
Signed-off-by: Loic Dachary <ldachary@redhat.com>