From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BB2AD767A4 for ; Tue, 19 Oct 2021 11:33:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 96D6C2AF39 for ; Tue, 19 Oct 2021 11:33:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 010AB2AF04 for ; Tue, 19 Oct 2021 11:33:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 98E61468DF for ; Tue, 19 Oct 2021 11:33:54 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 19 Oct 2021 11:33:45 +0200 Message-Id: <20211019093353.2451987-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211019093353.2451987-1-d.csapak@proxmox.com> References: <20211019093353.2451987-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.292 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager 03/11] api: cephfs: refactor {ls, create}_fs X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2021 09:33:56 -0000 no function change intended Signed-off-by: Dominik Csapak --- PVE/API2/Ceph/FS.pm | 22 ++++++---------------- PVE/Ceph/Tools.pm | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/PVE/API2/Ceph/FS.pm b/PVE/API2/Ceph/FS.pm index 82b5d616..cdced31a 100644 --- a/PVE/API2/Ceph/FS.pm +++ b/PVE/API2/Ceph/FS.pm @@ -59,15 +59,7 @@ __PACKAGE__->register_method ({ my $rados = PVE::RADOS->new(); - my $cephfs_list = $rados->mon_command({ prefix => "fs ls" }); - # we get something like: - #{ - # 'metadata_pool_id' => 2, - # 'data_pool_ids' => [ 1 ], - # 'metadata_pool' => 'cephfs_metadata', - # 'data_pools' => [ 'cephfs_data' ], - # 'name' => 'cephfs', - #} + my $cephfs_list = PVE::Ceph::Tools::ls_fs($rados); my $res = [ map {{ @@ -161,13 +153,11 @@ __PACKAGE__->register_method ({ push @created_pools, $pool_metadata; print "configuring new CephFS '$fs_name'\n"; - $rados->mon_command({ - prefix => "fs new", - fs_name => $fs_name, - metadata => $pool_metadata, - data => $pool_data, - format => 'plain', - }); + my $param = { + pool_metadata => $pool_metadata, + pool_data => $pool_data, + }; + PVE::Ceph::Tools::create_fs($fs_name, $param, $rados); }; if (my $err = $@) { $@ = undef; diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm index 74ead6f7..2f818276 100644 --- a/PVE/Ceph/Tools.pm +++ b/PVE/Ceph/Tools.pm @@ -304,6 +304,42 @@ sub destroy_pool { }); } +# we get something like: +#[{ +# 'metadata_pool_id' => 2, +# 'data_pool_ids' => [ 1 ], +# 'metadata_pool' => 'cephfs_metadata', +# 'data_pools' => [ 'cephfs_data' ], +# 'name' => 'cephfs', +#}] +sub ls_fs { + my ($rados) = @_; + + if (!defined($rados)) { + $rados = PVE::RADOS->new(); + } + + my $res = $rados->mon_command({ prefix => "fs ls" }); + + return $res; +} + +sub create_fs { + my ($fs, $param, $rados) = @_; + + if (!defined($rados)) { + $rados = PVE::RADOS->new(); + } + + $rados->mon_command({ + prefix => "fs new", + fs_name => $fs, + metadata => $param->{pool_metadata}, + data => $param->{pool_data}, + format => 'plain', + }); +} + sub setup_pve_symlinks { # fail if we find a real file instead of a link if (-f $ceph_cfgpath) { -- 2.30.2