From 48e8a06de1e7d6b6aba066fd1c56e9892fb04ffa Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 4 Jun 2019 14:47:48 +0200 Subject: [PATCH] ceph: add ceph-volume helper those will be needed for creation/destruction of nautilus osds Signed-off-by: Dominik Csapak --- PVE/Ceph/Tools.pm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index b74e2572..9610483a 100644 --- a/PVE/Ceph/Tools.pm +++ b/PVE/Ceph/Tools.pm @@ -6,8 +6,10 @@ use warnings; use File::Path; use File::Basename; use IO::File; +use JSON; use PVE::Tools qw(run_command dir_glob_foreach); +use PVE::Cluster qw(cfs_read_file); use PVE::RADOS; my $ccname = 'ceph'; # ceph cluster name @@ -27,6 +29,7 @@ my $ceph_service = { ceph_mgr => "/usr/bin/ceph-mgr", ceph_osd => "/usr/bin/ceph-osd", ceph_mds => "/usr/bin/ceph-mds", + ceph_volume => '/usr/sbin/ceph-volume', }; my $config_hash = { @@ -240,4 +243,34 @@ sub wipe_disks { } }; +# get ceph-volume managed osds +sub ceph_volume_list { + my $result = {}; + my $output = ''; + + if (!check_ceph_installed('ceph_volume', 1)) { + return $result; + } + + my $cmd = [$ceph_service->{ceph_volume}, 'lvm', 'list', '--format', 'json']; + run_command($cmd, outfunc => sub { + $output .= shift; + }); + + $result = eval { decode_json($output) }; + warn $@ if $@; + return $result; +} + +sub ceph_volume_zap { + my ($osdid, $destroy) = @_; + + die "no osdid given\n" if !defined($osdid); + + my $cmd = [$ceph_service->{ceph_volume}, 'lvm', 'zap', '--osd-id', $osdid]; + push @$cmd, '--destroy' if $destroy; + + run_command($cmd); +} + 1;