[pve-devel] [PATCH manager 09/20] ceph: add ceph-volume helper

Dominik Csapak d.csapak at proxmox.com
Tue Jun 4 14:47:48 CEST 2019


those will be needed for creation/destruction of nautilus osds

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 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;
-- 
2.11.0





More information about the pve-devel mailing list