Commit 3b51fd13 authored by Dietmar Maurer's avatar Dietmar Maurer

fix osd keyring, use tasks

parent 3712e45b
...@@ -567,7 +567,7 @@ __PACKAGE__->register_method ({ ...@@ -567,7 +567,7 @@ __PACKAGE__->register_method ({
} }
$cfg->{global}->{keyring} = '/etc/pve/priv/$cluster.$name.keyring'; $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}; $cfg->{global}->{'osd pool default size'} = $param->{size} if $param->{size};
...@@ -596,7 +596,7 @@ __PACKAGE__->register_method ({ ...@@ -596,7 +596,7 @@ __PACKAGE__->register_method ({
node => get_standard_option('pve-node'), node => get_standard_option('pve-node'),
}, },
}, },
returns => { type => 'null' }, returns => { type => 'string' },
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;
...@@ -604,20 +604,9 @@ __PACKAGE__->register_method ({ ...@@ -604,20 +604,9 @@ __PACKAGE__->register_method ({
&$setup_pve_symlinks(); &$setup_pve_symlinks();
if (! -f $pve_ckeyring_path) { my $rpcenv = PVE::RPCEnvironment::get();
run_command("ceph-authtool $pve_ckeyring_path --create-keyring " .
"--gen-key -n client.admin");
}
if (! -f $pve_mon_key_path) { my $authuser = $rpcenv->get_user();
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 $cfg = &$parse_ceph_config($pve_ceph_cfgpath); my $cfg = &$parse_ceph_config($pve_ceph_cfgpath);
...@@ -653,6 +642,23 @@ __PACKAGE__->register_method ({ ...@@ -653,6 +642,23 @@ __PACKAGE__->register_method ({
die "monitor address '$monaddr' already in use by '$monaddrhash->{$monaddr}'\n" die "monitor address '$monaddr' already in use by '$monaddrhash->{$monaddr}'\n"
if $monaddrhash->{$monaddr}; if $monaddrhash->{$monaddr};
my $worker = sub {
my $upid = shift;
if (! -f $pve_ckeyring_path) {
run_command("ceph-authtool $pve_ckeyring_path --create-keyring " .
"--gen-key -n client.admin");
}
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 $mondir = "/var/lib/ceph/mon/$ccname-$monid"; my $mondir = "/var/lib/ceph/mon/$ccname-$monid";
-d $mondir && die "monitor filesystem '$mondir' already exist\n"; -d $mondir && die "monitor filesystem '$mondir' already exist\n";
...@@ -686,9 +692,9 @@ __PACKAGE__->register_method ({ ...@@ -686,9 +692,9 @@ __PACKAGE__->register_method ({
&$write_ceph_config($cfg); &$write_ceph_config($cfg);
&$ceph_service_cmd('start', $monsection); &$ceph_service_cmd('start', $monsection);
};
return undef; return $rpcenv->fork_worker('cephcreatemon', $monsection, $authuser, $worker);
}}); }});
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
...@@ -708,10 +714,14 @@ __PACKAGE__->register_method ({ ...@@ -708,10 +714,14 @@ __PACKAGE__->register_method ({
}, },
}, },
}, },
returns => { type => 'null' }, returns => { type => 'string' },
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
&$check_ceph_inited(); &$check_ceph_inited();
my $cfg = &$parse_ceph_config($pve_ceph_cfgpath); my $cfg = &$parse_ceph_config($pve_ceph_cfgpath);
...@@ -731,6 +741,9 @@ __PACKAGE__->register_method ({ ...@@ -731,6 +741,9 @@ __PACKAGE__->register_method ({
die "can't remove last monitor\n" if scalar(@$monlist) <= 1; die "can't remove last monitor\n" if scalar(@$monlist) <= 1;
my $worker = sub {
my $upid = shift;
&$run_ceph_cmd(['mon', 'remove', $monid]); &$run_ceph_cmd(['mon', 'remove', $monid]);
eval { &$ceph_service_cmd('stop', $monsection); }; eval { &$ceph_service_cmd('stop', $monsection); };
...@@ -739,8 +752,9 @@ __PACKAGE__->register_method ({ ...@@ -739,8 +752,9 @@ __PACKAGE__->register_method ({
delete $cfg->{$monsection}; delete $cfg->{$monsection};
&$write_ceph_config($cfg); &$write_ceph_config($cfg);
File::Path::remove_tree($mondir); File::Path::remove_tree($mondir);
};
return undef; return $rpcenv->fork_worker('cephdestroymon', $monsection, $authuser, $worker);
}}); }});
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
...@@ -1076,16 +1090,18 @@ __PACKAGE__->register_method ({ ...@@ -1076,16 +1090,18 @@ __PACKAGE__->register_method ({
} }
}, },
}, },
returns => { type => 'null' }, returns => { type => 'string' },
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
&$check_ceph_inited(); &$check_ceph_inited();
&$setup_pve_symlinks(); &$setup_pve_symlinks();
print "create OSD on $param->{dev}\n";
-b $param->{dev} || die "no such block device '$param->{dev}'\n"; -b $param->{dev} || die "no such block device '$param->{dev}'\n";
my $disklist = list_disks(); my $disklist = list_disks();
...@@ -1108,11 +1124,17 @@ __PACKAGE__->register_method ({ ...@@ -1108,11 +1124,17 @@ __PACKAGE__->register_method ({
&$run_ceph_cmd(['auth', 'get', 'client.bootstrap-osd', '-o', $ceph_bootstrap_osd_keyring]); &$run_ceph_cmd(['auth', 'get', 'client.bootstrap-osd', '-o', $ceph_bootstrap_osd_keyring]);
}; };
my $worker = sub {
my $upid = shift;
print "create OSD on $param->{dev}\n";
run_command(['ceph-disk', 'prepare', '--zap-disk', '--fs-type', 'xfs', run_command(['ceph-disk', 'prepare', '--zap-disk', '--fs-type', 'xfs',
'--cluster', $ccname, '--cluster-uuid', $fsid, '--cluster', $ccname, '--cluster-uuid', $fsid,
'--', $param->{dev}]); '--', $param->{dev}]);
};
return undef; return $rpcenv->fork_worker('cephcreateods', $param->{dev}, $authuser, $worker);
}}); }});
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
...@@ -1132,17 +1154,19 @@ __PACKAGE__->register_method ({ ...@@ -1132,17 +1154,19 @@ __PACKAGE__->register_method ({
}, },
}, },
}, },
returns => { type => 'null' }, returns => { type => 'string' },
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
&$check_ceph_inited(); &$check_ceph_inited();
my $osdid = $param->{osdid}; my $osdid = $param->{osdid};
print "destroy OSD $param->{osdid}\n"; # fixme: not 100% sure what we should do here
# fixme: not sure what we should do here
my $stat = &$ceph_osd_status(); my $stat = &$ceph_osd_status();
...@@ -1164,6 +1188,11 @@ __PACKAGE__->register_method ({ ...@@ -1164,6 +1188,11 @@ __PACKAGE__->register_method ({
my $osdsection = "osd.$osdid"; my $osdsection = "osd.$osdid";
my $worker = sub {
my $upid = shift;
print "destroy OSD $param->{osdid}\n";
eval { &$ceph_service_cmd('stop', $osdsection); }; eval { &$ceph_service_cmd('stop', $osdsection); };
warn $@ if $@; warn $@ if $@;
...@@ -1175,8 +1204,9 @@ __PACKAGE__->register_method ({ ...@@ -1175,8 +1204,9 @@ __PACKAGE__->register_method ({
print "Remove OSD $osdsection\n"; print "Remove OSD $osdsection\n";
&$run_ceph_cmd(['osd', 'rm', $osdid]); &$run_ceph_cmd(['osd', 'rm', $osdid]);
};
return undef; return $rpcenv->fork_worker('cephdestroyods', $osdsection, $authuser, $worker);
}}); }});
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
......
...@@ -124,14 +124,12 @@ my $cmddef = { ...@@ -124,14 +124,12 @@ my $cmddef = {
}], }],
createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }], createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
destroypool => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ], destroypool => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'], { node => $nodename } ], createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'], { node => $nodename }, $upid_exit],
destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'], { node => $nodename } ], destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename } ], createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename }, $upid_exit],
destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename } ], destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename }, $upid_exit],
start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, $upid_exit],
$upid_exit], stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, $upid_exit],
stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename },
$upid_exit],
install => [ __PACKAGE__, 'install', [] ], install => [ __PACKAGE__, 'install', [] ],
purge => [ __PACKAGE__, 'purge', [] ], purge => [ __PACKAGE__, 'purge', [] ],
status => [ 'PVE::API2::Ceph', 'status', [], { node => $nodename }, sub { status => [ 'PVE::API2::Ceph', 'status', [], { node => $nodename }, sub {
......
...@@ -536,6 +536,10 @@ Ext.define('PVE.Utils', { statics: { ...@@ -536,6 +536,10 @@ Ext.define('PVE.Utils', { statics: {
srvstop: ['SRV', gettext('Stop') ], srvstop: ['SRV', gettext('Stop') ],
srvrestart: ['SRV', gettext('Restart') ], srvrestart: ['SRV', gettext('Restart') ],
srvreload: ['SRV', gettext('Reload') ], 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') ], imgcopy: ['', gettext('Copy data') ],
imgdel: ['', gettext('Erase data') ], imgdel: ['', gettext('Erase data') ],
download: ['', gettext('Download') ], download: ['', gettext('Download') ],
......
...@@ -484,7 +484,7 @@ Ext.define('PVE.CephCreateMon', { ...@@ -484,7 +484,7 @@ Ext.define('PVE.CephCreateMon', {
{ {
xtype: 'PVE.form.NodeSelector', xtype: 'PVE.form.NodeSelector',
submitValue: false, submitValue: false,
fieldLabel: gettext('Comment'), fieldLabel: gettext('Host'),
selectCurNode: true, selectCurNode: true,
allowBlank: false, allowBlank: false,
listeners: { listeners: {
...@@ -797,6 +797,7 @@ Ext.define('PVE.node.CephStatus', { ...@@ -797,6 +797,7 @@ Ext.define('PVE.node.CephStatus', {
} }
var txt = value.overall_status; var txt = value.overall_status;
Ext.Array.each(value.summary, function(d) { Ext.Array.each(value.summary, function(d) {
txt += " " + d.summary + ';'; txt += " " + d.summary + ';';
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment