[pve-devel] [PATCH storage v3 04/20] rbd: implement pveceph flag handling

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Aug 31 11:38:07 CEST 2017


add /etc/pve/ceph.conf to commands / option strings instead
of the monitor list provided via the 'monhost' option.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
changes since v2:
- split check_monhost_pveceph into own patch, as check_config implementation

 PVE/Storage/RBDPlugin.pm | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index e976754..a74502d 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -10,6 +10,8 @@ use PVE::JSONSchema qw(get_standard_option);
 
 use base qw(PVE::Storage::Plugin);
 
+my $pveceph_config = '/etc/pve/ceph.conf';
+
 my $rbd_unittobytes = {
     "k"  => 1024,
     "M"  => 1024*1024,
@@ -40,13 +42,14 @@ my $hostlist = sub {
 my $build_cmd = sub {
     my ($binary, $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 = [$binary, '-p', $pool, '-m', $monhost];
+    my $cmd = [$binary, '-p', $pool];
+
+    push @$cmd, '-m', $hostlist->($scfg->{monhost}, ',') if $scfg->{monhost};
+    push @$cmd, '-c', $pveceph_config if $scfg->{pveceph};
 
     if (-e $keyring) {
 	push @$cmd, '-n', "client.$username";
@@ -59,7 +62,11 @@ my $build_cmd = sub {
     my $cephconfig = "/etc/pve/priv/ceph/${storeid}.conf";
 
     if (-e $cephconfig) {
-	push @$cmd, '-c', $cephconfig;
+	if ($scfg->{pveceph}) {
+	    warn "ignoring custom ceph config for storage '$storeid', 'pveceph' is set!\n";
+	} else {
+	    push @$cmd, '-c', $cephconfig;
+	}
     }
 
     push @$cmd, $op;
@@ -310,12 +317,18 @@ sub path {
     my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
     return ("/dev/rbd/$pool/$name", $vmid, $vtype) if $scfg->{krbd};
 
-    my $monhost = &$hostlist($scfg->{monhost}, ';');
-    $monhost =~ s/:/\\:/g;
-
     my $username =  $scfg->{username} ? $scfg->{username} : 'admin';
 
-    my $path = "rbd:$pool/$name:mon_host=$monhost";
+    my $path = "rbd:$pool/$name";
+
+    if ($scfg->{monhost}) {
+	my $monhost = $hostlist->($scfg->{monhost}, ';');
+	$monhost =~ s/:/\\:/g;
+	$path .= ":mon_host=$monhost";
+    }
+
+    $path .= ":conf=$pveceph_config" if $scfg->{pveceph};
+
     my $keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
 
     if (-e $keyring) {
@@ -327,7 +340,11 @@ sub path {
     my $cephconfig = "/etc/pve/priv/ceph/${storeid}.conf";
 
     if (-e $cephconfig) {
-	$path .= ":conf=$cephconfig";
+	if ($scfg->{pveceph}) {
+	    warn "ignoring custom ceph config for storage '$storeid', 'pveceph' is set!\n";
+	} else {
+	    $path .= ":conf=$cephconfig";
+	}
     }
 
     return ($path, $vmid, $vtype);
-- 
2.11.0





More information about the pve-devel mailing list