my $ZPOOL = "/sbin/zpool";
my $SGDISK = "/sbin/sgdisk";
my $PVS = "/sbin/pvs";
+my $LVS = "/sbin/lvs";
my $UDEVADM = "/bin/udevadm";
sub verify_blockdev_path {
return $journalhash;
}
+# 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
+ 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;
+ # we use autovivification here to not concern us with
+ # creation of 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');
+ } else {
+ # if $foo is undef $foo++ results in '1' (and is well defined)
+ $result->{$dev}->{$type}++;
+ }
+ }
+ });
+
+ return $result;
+}
+
sub get_udev_info {
my ($dev) = @_;
};
my $journalhash = get_ceph_journals();
+ my $ceph_volume_infos = get_ceph_volume_infos();
my $zfslist = get_zfs_devices();
}
});
+ if ($ceph_volume_infos->{$devpath}) {
+ $journal_count += $ceph_volume_infos->{$devpath}->{journal} // 0;
+ $db_count += $ceph_volume_infos->{$devpath}->{db} // 0;
+ $wal_count += $ceph_volume_infos->{$devpath}->{wal} // 0;
+ if ($ceph_volume_infos->{$devpath}->{osdid}) {
+ $osdid = $ceph_volume_infos->{$devpath}->{osdid};
+ $bluestore = 1 if $ceph_volume_infos->{$devpath}->{bluestore};
+ }
+ }
+
$used = 'mounted' if $found_mountpoints && !$used;
$used = 'LVM' if $found_lvm && !$used;
$used = 'ZFS' if $found_zfs && !$used;
"vendor" : "ATA",
"wwn" : "0x0000000000000000",
"devpath" : "/dev/sdd"
+ },
+ "sdg" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdg",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "type" : "hdd",
+ "bluestore": 1,
+ "osdid" : 1
+ },
+ "sdh" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdh",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "journals": 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "type" : "hdd",
+ "osdid" : -1
+ },
+ "sdi" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdi",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "type" : "hdd",
+ "db": 1,
+ "osdid" : -1
+ },
+ "sdj" : {
+ "serial" : "SERIAL1",
+ "vendor" : "ATA",
+ "wwn" : "0x0000000000000000",
+ "devpath" : "/dev/sdj",
+ "model" : "MODEL1",
+ "used" : "LVM",
+ "wearout" : "N/A",
+ "health" : "UNKNOWN",
+ "gpt" : 1,
+ "size" : 1536000,
+ "rpm" : 0,
+ "bluestore": 0,
+ "type" : "hdd",
+ "osdid" : 2
}
}