[pve-devel] [PATCH pve-manager 3/3] Now pvecephy can also createmon with Infernalis and Hammer.

Wolfgang Link w.link at proxmox.com
Tue May 24 15:58:12 CEST 2016


Ceph changed user name from root to ceph.
And for startup systemd is used instead of sysvinit.
---
 PVE/API2/Ceph.pm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 58e5b35..2206197 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -226,6 +226,7 @@ __PACKAGE__->register_method ({
 	if (! -f $ceph_bootstrap_osd_keyring) {
 	    my $bindata = $rados->mon_command({ prefix => 'auth get', entity => 'client.bootstrap-osd', format => 'plain' });
 	    PVE::Tools::file_set_contents($ceph_bootstrap_osd_keyring, $bindata);
+
 	};
         
 	my $worker = sub {
@@ -841,6 +842,8 @@ __PACKAGE__->register_method ({
 
 	my $monaddrhash = {}; 
 
+	my $systemd = PVE::CephTools::systemd_managed();
+
 	foreach my $section (keys %$cfg) {
 	    next if $section eq 'global';
 	    my $d = $cfg->{$section};
@@ -878,6 +881,7 @@ __PACKAGE__->register_method ({
 
 	my $worker = sub  {
 	    my $upid = shift;
+	    my $uid = 0;
 
 	    my $pve_ckeyring_path = PVE::CephTools::get_config('pve_ckeyring_path');
 
@@ -888,11 +892,17 @@ __PACKAGE__->register_method ({
 
 	    my $pve_mon_key_path = PVE::CephTools::get_config('pve_mon_key_path');
 	    if (! -f $pve_mon_key_path) {
+
+		$uid = getpwnam('ceph') if $systemd;
+
 		run_command("cp $pve_ckeyring_path $pve_mon_key_path.tmp");
-		run_command("ceph-authtool $pve_mon_key_path.tmp -n client.admin --set-uid=0 " .
+		my $cmd = "ceph-authtool $pve_mon_key_path.tmp -n client.admin --set-uid=0 " .
 			    "--cap mds 'allow' " .
 			    "--cap osd 'allow *' " .
-			    "--cap mon 'allow *'");
+			    "--cap mon 'allow *' ";
+		$cmd .= "> /etc/ceph/ceph.client.admin.keyring" if $systemd;
+		run_command($cmd);
+		run_command("chown ceph:ceph /etc/ceph/ceph.client.admin.keyring") if $systemd;
 		run_command("ceph-authtool $pve_mon_key_path.tmp --gen-key -n mon. --cap mon 'allow *'");
 		run_command("mv $pve_mon_key_path.tmp $pve_mon_key_path");
 	    }
@@ -906,6 +916,7 @@ __PACKAGE__->register_method ({
 	
 	    eval {
 		mkdir $mondir;
+		run_command("chown ceph:ceph $mondir") if $systemd;
 
 		if ($moncount > 0) {
 		    my $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
@@ -916,6 +927,8 @@ __PACKAGE__->register_method ({
 		}
 
 		run_command("ceph-mon --mkfs -i $monid --monmap $monmap --keyring $pve_mon_key_path");
+		run_command("chown ceph:ceph -R $mondir") if $systemd;
+
 	    };
 	    my $err = $@;
 	    unlink $monmap;
-- 
2.1.4





More information about the pve-devel mailing list