[pve-devel] [PATCH storage v4 02/19] rbd: refactor cmdline helpers

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Sep 5 14:59:31 CEST 2017


these were line by line identical except for the binary path

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 PVE/Storage/RBDPlugin.pm | 38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 30f7696..12a3458 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -37,8 +37,8 @@ my $hostlist = sub {
     } @monhostlist);
 };
 
-my $rbd_cmd = sub {
-    my ($scfg, $storeid, $op, @options) = @_;
+my $build_cmd = sub {
+    my ($binary, $scfg, $storeid, $op, @options) = @_;
 
     my $monhost = &$hostlist($scfg->{monhost}, ',');
 
@@ -46,7 +46,7 @@ my $rbd_cmd = sub {
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
     my $username =  $scfg->{username} ? $scfg->{username} : 'admin';
 
-    my $cmd = ['/usr/bin/rbd', '-p', $pool, '-m', $monhost]; 
+    my $cmd = [$binary, '-p', $pool, '-m', $monhost];
 
     if (-e $keyring) {
 	push @$cmd, '-n', "client.$username";
@@ -69,36 +69,16 @@ my $rbd_cmd = sub {
     return $cmd;
 };
 
-my $rados_cmd = sub {
+my $rbd_cmd = sub {
     my ($scfg, $storeid, $op, @options) = @_;
 
-    my $monhost = &$hostlist($scfg->{monhost}, ',');
-
-    my $keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-    my $username =  $scfg->{username} ? $scfg->{username} : 'admin';
-
-    my $cmd = ['/usr/bin/rados', '-p', $pool, '-m', $monhost];
-
-    if (-e $keyring) {
-	push @$cmd, '-n', "client.$username";
-	push @$cmd, '--keyring', $keyring;
-	push @$cmd, '--auth_supported', 'cephx';
-    } else {
-	push @$cmd, '--auth_supported', 'none';
-    }
-
-    my $cephconfig = "/etc/pve/priv/ceph/${storeid}.conf";
-
-    if (-e $cephconfig) {
-	push @$cmd, '-c', $cephconfig;
-    }
-
-    push @$cmd, $op;
+    return $build_cmd->('/usr/bin/rbd', $scfg, $storeid, $op, @options);
+};
 
-    push @$cmd, @options if scalar(@options);
+my $rados_cmd = sub {
+    my ($scfg, $storeid, $op, @options) = @_;
 
-    return $cmd;
+    return $build_cmd->('/usr/bin/rados', $scfg, $storeid, $op, @options);
 };
 
 # needed for volumes created using ceph jewel (or higher)
-- 
2.11.0





More information about the pve-devel mailing list