]> git.proxmox.com Git - pve-storage.git/commitdiff
rbd: refactor cmdline helpers
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 5 Sep 2017 12:59:31 +0000 (14:59 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 7 Sep 2017 09:35:00 +0000 (11:35 +0200)
these were line by line identical except for the binary path

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/Storage/RBDPlugin.pm

index 4c2967c7ee9d1ea2ffd15dbab497a6bd2fb12708..2a176a74a1649b25d6fd90c37bc92bbbca90c9b7 100644 (file)
@@ -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)