[pve-devel] [v2 storage 3/4] refactor cmdline helpers

Fabian Gr├╝nbichler f.gruenbichler at proxmox.com
Tue Aug 29 13:04:25 CEST 2017


these were line by line identical except for the binary path

Signed-off-by: Fabian Gr├╝nbichler <f.gruenbichler at proxmox.com>
---
new in v2

 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 70d1fda..55fd252 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