all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 03/11] api: cephfs: refactor {ls, create}_fs
Date: Tue, 19 Oct 2021 11:33:45 +0200	[thread overview]
Message-ID: <20211019093353.2451987-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211019093353.2451987-1-d.csapak@proxmox.com>

no function change intended

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





  parent reply	other threads:[~2021-10-19  9:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19  9:33 [pve-devel] [PATCH storage/manager] fix #3616: support multiple ceph filesystems Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH storage 1/1] cephfs: add support for " Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 01/11] api: ceph-mds: get mds state when multple ceph filesystems exist Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 02/11] ui: ceph: catch missing version for service list Dominik Csapak
2021-10-19  9:33 ` Dominik Csapak [this message]
2021-10-19  9:33 ` [pve-devel] [PATCH manager 04/11] api: cephfs: more checks on fs create Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 05/11] ui: ceph/ServiceList: refactor controller out Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 06/11] ui: ceph/fs: show fs for active mds Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 07/11] api: cephfs: add 'fs-name' for cephfs storage Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 08/11] ui: storage/cephfs: make ceph fs selectable Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 09/11] ui: ceph/fs: allow creating multiple cephfs Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 10/11] api: cephfs: add destroy cephfs api call Dominik Csapak
2021-10-19  9:33 ` [pve-devel] [PATCH manager 11/11] ui: ceph/fs: allow destroying cephfs Dominik Csapak
2021-10-20 14:40 ` [pve-devel] [PATCH storage/manager] fix #3616: support multiple ceph filesystems Aaron Lauterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019093353.2451987-5-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal