- my $journalhash = {};
-
- my $journal_uuid = '45b0969e-9b03-4f30-b4c6-b4b80ceff106';
- my $db_uuid = '30cd0809-c2b2-499c-8879-2d6b78529876';
- my $wal_uuid = '5ce17fce-4087-4169-b7ff-056cc58473f9';
- my $block_uuid = 'cafecafe-9b03-4f30-b4c6-b4b80ceff106';
-
- dir_glob_foreach('/dev/disk/by-parttypeuuid', "($journal_uuid|$db_uuid|$wal_uuid|$block_uuid)\..+", sub {
- my ($entry, $type) = @_;
- my $real_dev = abs_path("/dev/disk/by-parttypeuuid/$entry");
- if ($type eq $journal_uuid) {
- $journalhash->{$real_dev} = 1;
- } elsif ($type eq $db_uuid) {
- $journalhash->{$real_dev} = 2;
- } elsif ($type eq $wal_uuid) {
- $journalhash->{$real_dev} = 3;
- } elsif ($type eq $block_uuid) {
- $journalhash->{$real_dev} = 4;
+ my ($parttype_map) = @_;
+ my $res = {};
+
+ my $uuids = {
+ '45b0969e-9b03-4f30-b4c6-b4b80ceff106' => 1, # journal
+ '30cd0809-c2b2-499c-8879-2d6b78529876' => 2, # db
+ '5ce17fce-4087-4169-b7ff-056cc58473f9' => 3, # wal
+ 'cafecafe-9b03-4f30-b4c6-b4b80ceff106' => 4, # block
+ };
+
+ $res = $get_devices_by_partuuid->($parttype_map, $uuids, $res);
+
+ return $res;
+}
+
+# reads the lv_tags and matches them with the devices
+sub get_ceph_volume_infos {
+ my $result = {};
+
+ my $cmd = [ $LVS, '-S', 'lv_name=~^osd-', '-o', 'devices,lv_name,lv_tags',
+ '--noheadings', '--readonly', '--separator', ';' ];
+
+ run_command($cmd, outfunc => sub {
+ my $line = shift;
+ $line =~ s/(?:^\s+)|(?:\s+$)//g; # trim whitespaces
+
+ my $fields = [ split(';', $line) ];
+
+ # lvs syntax is /dev/sdX(Y) where Y is the start (which we do not need)
+ my ($dev) = $fields->[0] =~ m|^(/dev/[a-z]+)|;
+ if ($fields->[1] =~ m|^osd-([^-]+)-|) {
+ my $type = $1;
+ # $result autovivification is wanted, to not creating empty hashes
+ if (($type eq 'block' || $type eq 'data') && $fields->[2] =~ m/ceph.osd_id=([^,]+)/) {
+ $result->{$dev}->{osdid} = $1;
+ $result->{$dev}->{bluestore} = ($type eq 'block');
+ if ($fields->[2] =~ m/ceph\.encrypted=1/) {
+ $result->{$dev}->{encrypted} = 1;
+ }
+ } else {
+ # undef++ becomes '1' (see `perldoc perlop`: Auto-increment)
+ $result->{$dev}->{$type}++;
+ }