]> git.proxmox.com Git - pve-manager.git/commitdiff
fix osd keyring, use tasks
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 22 Nov 2013 07:41:37 +0000 (08:41 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 22 Nov 2013 07:41:37 +0000 (08:41 +0100)
PVE/API2/Ceph.pm
bin/pveceph
www/manager/Utils.js
www/manager/node/Ceph.js

index b01663e36b808f49cc64b247b3ee4e7be17301f4..a3dc322cc8265992aa0a6dffc2bc1d407e8991d8 100644 (file)
@@ -567,7 +567,7 @@ __PACKAGE__->register_method ({
        }
        
        $cfg->{global}->{keyring} = '/etc/pve/priv/$cluster.$name.keyring';
-       $cfg->{osd}->{keyring} = "/var/lib/ceph/osd/ceph-$id/keyring";
+       $cfg->{osd}->{keyring} = '/var/lib/ceph/osd/ceph-$id/keyring';
 
        $cfg->{global}->{'osd pool default size'} = $param->{size} if $param->{size};
        
@@ -596,7 +596,7 @@ __PACKAGE__->register_method ({
            node => get_standard_option('pve-node'),
        },
     },
-    returns => { type => 'null' },
+    returns => { type => 'string' },
     code => sub {
        my ($param) = @_;
 
@@ -604,20 +604,9 @@ __PACKAGE__->register_method ({
 
        &$setup_pve_symlinks();
 
-       if (! -f $pve_ckeyring_path) {
-           run_command("ceph-authtool $pve_ckeyring_path --create-keyring " .
-                       "--gen-key -n client.admin");
-       }
+       my $rpcenv = PVE::RPCEnvironment::get();
 
-       if (! -f $pve_mon_key_path) {
-           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 " .
-                       "--cap mds 'allow' " .
-                       "--cap osd 'allow *' " .
-                       "--cap mon 'allow *'");
-           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");
-       }
+       my $authuser = $rpcenv->get_user();
 
        my $cfg = &$parse_ceph_config($pve_ceph_cfgpath);
 
@@ -653,42 +642,59 @@ __PACKAGE__->register_method ({
        die "monitor address '$monaddr' already in use by '$monaddrhash->{$monaddr}'\n" 
            if $monaddrhash->{$monaddr};
 
+       my $worker = sub  {
+           my $upid = shift;
 
-       my $mondir =  "/var/lib/ceph/mon/$ccname-$monid";
-       -d $mondir && die "monitor filesystem '$mondir' already exist\n";
-       my $monmap = "/tmp/monmap";
-       
-       eval {
-           mkdir $mondir;
+           if (! -f $pve_ckeyring_path) {
+               run_command("ceph-authtool $pve_ckeyring_path --create-keyring " .
+                           "--gen-key -n client.admin");
+           }
 
-           if ($moncount > 0) {
-               my $monstat = ceph_mon_status(); # online test
-               &$run_ceph_cmd(['mon', 'getmap', '-o', $monmap]);
-           } else {
-               run_command("monmaptool --create --clobber --add $monid $monaddr --print $monmap");
+           if (! -f $pve_mon_key_path) {
+               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 " .
+                           "--cap mds 'allow' " .
+                           "--cap osd 'allow *' " .
+                           "--cap mon 'allow *'");
+               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");
            }
 
-           run_command("ceph-mon --mkfs -i $monid --monmap $monmap --keyring $pve_mon_key_path");
-       };
-       my $err = $@;
-       unlink $monmap;
-       if ($err) {
-           File::Path::remove_tree($mondir);
-           die $err;
-       }
+           my $mondir =  "/var/lib/ceph/mon/$ccname-$monid";
+           -d $mondir && die "monitor filesystem '$mondir' already exist\n";
+           my $monmap = "/tmp/monmap";
+       
+           eval {
+               mkdir $mondir;
+
+               if ($moncount > 0) {
+                   my $monstat = ceph_mon_status(); # online test
+                   &$run_ceph_cmd(['mon', 'getmap', '-o', $monmap]);
+               } else {
+                   run_command("monmaptool --create --clobber --add $monid $monaddr --print $monmap");
+               }
 
-       $cfg->{$monsection} = {
-           'host' => $monname,
-           'mon addr' => $monaddr,
-       };
+               run_command("ceph-mon --mkfs -i $monid --monmap $monmap --keyring $pve_mon_key_path");
+           };
+           my $err = $@;
+           unlink $monmap;
+           if ($err) {
+               File::Path::remove_tree($mondir);
+               die $err;
+           }
 
-       &$write_ceph_config($cfg);
+           $cfg->{$monsection} = {
+               'host' => $monname,
+               'mon addr' => $monaddr,
+           };
 
-       &$ceph_service_cmd('start', $monsection);
+           &$write_ceph_config($cfg);
 
-       return undef;
+           &$ceph_service_cmd('start', $monsection);
+       };
 
+       return $rpcenv->fork_worker('cephcreatemon', $monsection, $authuser, $worker);
     }});
 
 __PACKAGE__->register_method ({
@@ -708,10 +714,14 @@ __PACKAGE__->register_method ({
            },
        },
     },
-    returns => { type => 'null' },
+    returns => { type => 'string' },
     code => sub {
        my ($param) = @_;
 
+       my $rpcenv = PVE::RPCEnvironment::get();
+
+       my $authuser = $rpcenv->get_user();
+
        &$check_ceph_inited();
 
        my $cfg = &$parse_ceph_config($pve_ceph_cfgpath);
@@ -731,16 +741,20 @@ __PACKAGE__->register_method ({
 
        die "can't remove last monitor\n" if scalar(@$monlist) <= 1;
 
-       &$run_ceph_cmd(['mon', 'remove', $monid]);
+       my $worker = sub {
+           my $upid = shift;
 
-       eval { &$ceph_service_cmd('stop', $monsection); };
-       warn $@ if $@;
+           &$run_ceph_cmd(['mon', 'remove', $monid]);
 
-       delete $cfg->{$monsection};
-       &$write_ceph_config($cfg);
-       File::Path::remove_tree($mondir);
+           eval { &$ceph_service_cmd('stop', $monsection); };
+           warn $@ if $@;
 
-       return undef;
+           delete $cfg->{$monsection};
+           &$write_ceph_config($cfg);
+           File::Path::remove_tree($mondir);
+       };
+
+       return $rpcenv->fork_worker('cephdestroymon', $monsection,  $authuser, $worker);
     }});
 
 __PACKAGE__->register_method ({
@@ -1076,16 +1090,18 @@ __PACKAGE__->register_method ({
            }
        },
     },
-    returns => { type => 'null' },
+    returns => { type => 'string' },
     code => sub {
        my ($param) = @_;
 
+       my $rpcenv = PVE::RPCEnvironment::get();
+
+       my $authuser = $rpcenv->get_user();
+
        &$check_ceph_inited();
 
        &$setup_pve_symlinks();
 
-       print "create OSD on $param->{dev}\n";
-
        -b  $param->{dev} || die "no such block device '$param->{dev}'\n";
 
        my $disklist = list_disks();
@@ -1108,11 +1124,17 @@ __PACKAGE__->register_method ({
            &$run_ceph_cmd(['auth', 'get', 'client.bootstrap-osd', '-o', $ceph_bootstrap_osd_keyring]);
        };
 
-       run_command(['ceph-disk', 'prepare', '--zap-disk', '--fs-type', 'xfs',
-                    '--cluster', $ccname, '--cluster-uuid', $fsid,
-                    '--', $param->{dev}]);
+       my $worker = sub {
+           my $upid = shift;
 
-       return undef;
+           print "create OSD on $param->{dev}\n";
+
+           run_command(['ceph-disk', 'prepare', '--zap-disk', '--fs-type', 'xfs',
+                        '--cluster', $ccname, '--cluster-uuid', $fsid,
+                        '--', $param->{dev}]);
+       };
+
+       return $rpcenv->fork_worker('cephcreateods', $param->{dev},  $authuser, $worker);
     }});
 
 __PACKAGE__->register_method ({
@@ -1132,17 +1154,19 @@ __PACKAGE__->register_method ({
            },
        },
     },
-    returns => { type => 'null' },
+    returns => { type => 'string' },
     code => sub {
        my ($param) = @_;
 
+       my $rpcenv = PVE::RPCEnvironment::get();
+
+       my $authuser = $rpcenv->get_user();
+
        &$check_ceph_inited();
 
        my $osdid = $param->{osdid};
 
-       print "destroy OSD $param->{osdid}\n";
-
-       # fixme: not sure what we should do here
+       # fixme: not 100% sure what we should do here
  
        my $stat = &$ceph_osd_status();
 
@@ -1164,19 +1188,25 @@ __PACKAGE__->register_method ({
 
        my $osdsection = "osd.$osdid";  
 
-       eval { &$ceph_service_cmd('stop', $osdsection); };
-       warn $@ if $@;
+       my $worker = sub {
+           my $upid = shift;
 
-       print "Remove $osdsection from the CRUSH map\n";
-       &$run_ceph_cmd(['osd', 'crush', 'remove', $osdid]);
+           print "destroy OSD $param->{osdid}\n";
 
-       print "Remove the $osdsection authentication key.\n";
-       &$run_ceph_cmd(['auth', 'del', $osdsection]);
+           eval { &$ceph_service_cmd('stop', $osdsection); };
+           warn $@ if $@;
 
-       print "Remove OSD $osdsection\n";
-       &$run_ceph_cmd(['osd', 'rm', $osdid]);
+           print "Remove $osdsection from the CRUSH map\n";
+           &$run_ceph_cmd(['osd', 'crush', 'remove', $osdid]);
 
-       return undef;
+           print "Remove the $osdsection authentication key.\n";
+           &$run_ceph_cmd(['auth', 'del', $osdsection]);
+
+           print "Remove OSD $osdsection\n";
+           &$run_ceph_cmd(['osd', 'rm', $osdid]);
+       };
+
+       return $rpcenv->fork_worker('cephdestroyods', $osdsection,  $authuser, $worker);
     }});
 
 __PACKAGE__->register_method ({
index f9844604875867d41bef2b1557485673b4ac9046..96ca63c96b9c69f8c7d4bd2f1870f90c28396ee9 100755 (executable)
@@ -124,14 +124,12 @@ my $cmddef = {
     }],
     createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
     destroypool => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
-    createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'], { node => $nodename } ],
-    destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'], { node => $nodename } ],
-    createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename } ],
-    destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename } ],
-    start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, 
-              $upid_exit],
-    stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, 
-             $upid_exit],
+    createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'], { node => $nodename }, $upid_exit],
+    destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
+    createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename }, $upid_exit],
+    destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename }, $upid_exit],
+    start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, $upid_exit],
+    stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, $upid_exit],
     install => [ __PACKAGE__, 'install', [] ],
     purge => [  __PACKAGE__, 'purge', [] ],
     status => [ 'PVE::API2::Ceph', 'status', [], { node => $nodename }, sub {
index 9cd9959da245c9b5f191a1e3c49db43c93704f5c..9d06efbe2766173152680cbe783924ce38276baf 100644 (file)
@@ -536,6 +536,10 @@ Ext.define('PVE.Utils', { statics: {
        srvstop: ['SRV', gettext('Stop') ],
        srvrestart: ['SRV', gettext('Restart') ],
        srvreload: ['SRV', gettext('Reload') ],
+       cephcreatemon: ['Ceph Monitor', gettext('Create') ],
+       cephdestroymon: ['Ceph Monitor', gettext('Destroy') ],
+       cephcreateosd: ['Ceph OSD', gettext('Create') ],
+       cephdestroyosd: ['Ceph OSD', gettext('Destroy') ],
        imgcopy: ['', gettext('Copy data') ],
        imgdel: ['', gettext('Erase data') ],
        download: ['', gettext('Download') ],
index 505a4745d0d6b572bb8126ec12a51f639ce29d0c..861f4a6764bb90150268d70be9a89f06d5f171da 100644 (file)
@@ -484,7 +484,7 @@ Ext.define('PVE.CephCreateMon', {
                {
                   xtype: 'PVE.form.NodeSelector',
                   submitValue: false,
-                  fieldLabel: gettext('Comment'),
+                  fieldLabel: gettext('Host'),
                   selectCurNode: true,
                   allowBlank: false,
                   listeners: {
@@ -797,6 +797,7 @@ Ext.define('PVE.node.CephStatus', {
            }
 
            var txt = value.overall_status;
+
            Ext.Array.each(value.summary, function(d) {
                txt += " " + d.summary + ';';
            });