my $osdstat;
foreach my $d (@$osdlist) {
- $osdstat->{$d->{osd}} = $d if defined($d->{osd});
+ $osdstat->{$d->{osd}} = $d if defined($d->{osd});
}
if (defined($osdid)) {
die "no such OSD '$osdid'\n" if !$osdstat->{$osdid};
my $get_osd_usage = sub {
my ($rados) = @_;
- my $osdlist = $rados->mon_command({ prefix => 'pg dump',
+ my $osdlist = $rados->mon_command({ prefix => 'pg dump',
dumpcontents => [ 'osds' ]}) || [];
my $osdstat;
foreach my $d (@$osdlist) {
- $osdstat->{$d->{osd}} = $d if defined($d->{osd});
+ $osdstat->{$d->{osd}} = $d if defined($d->{osd});
}
return $osdstat;
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
my $newnodes = {};
foreach my $e (@{$res->{nodes}}) {
$nodes->{$e->{id}} = $e;
-
- my $new = {
- id => $e->{id},
- name => $e->{name},
+
+ my $new = {
+ id => $e->{id},
+ name => $e->{name},
type => $e->{type}
};
proxyto => 'node',
protected => 1,
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
dev => {
die "unable to get device info for '$devname'\n"
if !$diskinfo;
- die "device '$param->{dev}' is in use\n"
+ die "device '$param->{dev}' is in use\n"
if $diskinfo->{used};
my $devpath = $diskinfo->{devpath};
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 {
my $upid = shift;
} else {
push @$cmd, $devpath;
}
-
+
run_command($cmd);
};
proxyto => 'node',
protected => 1,
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
osdid => {
my $upid = shift;
# reopen with longer timeout
- $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
+ $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
print "destroy OSD $osdsection\n";
my $journal_part;
my $data_part;
-
+
if ($param->{cleanup}) {
my $jpath = "$mountpoint/journal";
$journal_part = abs_path($jpath);
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
osdid => {
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
osdid => {
my $pve_osd_default_journal_size = 1024*5;
__PACKAGE__->register_method ({
- subclass => "PVE::API2::CephOSD",
+ subclass => "PVE::API2::CephOSD",
path => 'osd',
});
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
type => {
}
$d->{dev} = "/dev/$dev";
- push @$res, $d;
+ push @$res, $d;
}
return $res;
},
description => "Get Ceph configuration.",
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
my $mons = $monstat->{monmap}->{mons};
foreach my $d (@$mons) {
next if !defined($d->{name});
- $monhash->{$d->{name}}->{rank} = $d->{rank};
+ $monhash->{$d->{name}}->{rank} = $d->{rank};
$monhash->{$d->{name}}->{addr} = $d->{addr};
if (grep { $_ eq $d->{rank} } @{$monstat->{quorum}}) {
$monhash->{$d->{name}}->{quorum} = 1;
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
network => {
- description => "Use specific network for all ceph related traffic",
+ description => "Use specific network for all ceph related traffic",
type => 'string', format => 'CIDR',
optional => 1,
maxLength => 128,
'mon allow pool delete' => 'true',
};
- # this does not work for default pools
+ # this does not work for default pools
#'osd pool default pg num' => $pg_num,
- #'osd pool default pgp num' => $pg_num,
+ #'osd pool default pgp num' => $pg_num,
}
-
+
$cfg->{global}->{keyring} = '/etc/pve/priv/$cluster.$name.keyring';
$cfg->{osd}->{keyring} = '/var/lib/ceph/osd/ceph-$id/keyring';
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
id => {
my $moncount = 0;
- my $monaddrhash = {};
+ my $monaddrhash = {};
my $systemd_managed = PVE::CephTools::systemd_managed();
my $monid = $param->{id} // $param->{node};
- my $monsection = "mon.$monid";
+ my $monsection = "mon.$monid";
my $ip;
if (my $pubnet = $cfg->{global}->{'public network'}) {
$ip = &$find_node_ip($pubnet);
my $monname = $param->{node};
die "monitor '$monsection' already exists\n" if $cfg->{$monsection};
- 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};
my $worker = sub {
my $mondir = "/var/lib/ceph/mon/$ccname-$monid";
-d $mondir && die "monitor filesystem '$mondir' already exist\n";
-
+
my $monmap = "/tmp/monmap";
my $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
monid => {
PVE::CephTools::check_ceph_inited();
my $cfg = PVE::CephTools::parse_ceph_config();
-
+
my $monid = $param->{monid};
- my $monsection = "mon.$monid";
+ my $monsection = "mon.$monid";
my $rados = PVE::RADOS->new();
my $monstat = $rados->mon_command({ prefix => 'mon_status' });
my $monlist = $monstat->{monmap}->{mons};
- die "no such monitor id '$monid'\n"
+ die "no such monitor id '$monid'\n"
if !defined($cfg->{$monsection});
my $ccname = PVE::CephTools::get_config('ccname');
my $upid = shift;
# reopen with longer timeout
- $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
+ $rados = PVE::RADOS->new(timeout => PVE::CephTools::get_config('long_rados_timeout'));
$rados->mon_command({ prefix => "mon remove", name => $monid, format => 'plain' });
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
service => {
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
service => {
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
name => {
my $pve_ckeyring_path = PVE::CephTools::get_config('pve_ckeyring_path');
- die "not fully configured - missing '$pve_ckeyring_path'\n"
+ die "not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
my $pg_num = $param->{pg_num} || 64;
my $ruleset = $param->{crush_ruleset} || 0;
my $rados = PVE::RADOS->new();
- $rados->mon_command({
+ $rados->mon_command({
prefix => "osd pool create",
pool => $param->{name},
pg_num => int($pg_num),
format => 'plain',
});
- $rados->mon_command({
+ $rados->mon_command({
prefix => "osd pool set",
pool => $param->{name},
var => 'min_size',
format => 'plain',
});
- $rados->mon_command({
+ $rados->mon_command({
prefix => "osd pool set",
pool => $param->{name},
var => 'size',
});
if (defined($param->{crush_ruleset})) {
- $rados->mon_command({
+ $rados->mon_command({
prefix => "osd pool set",
pool => $param->{name},
var => 'crush_ruleset',
check => ['perm', '/', [ 'Sys.Modify' ]],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
name => {
my $rados = PVE::RADOS->new();
# fixme: '--yes-i-really-really-mean-it'
- $rados->mon_command({
+ $rados->mon_command({
prefix => "osd pool delete",
pool => $param->{name},
pool2 => $param->{name},
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
},
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
my $mapdata = "/var/tmp/ceph-crush.txt.$$";
my $rados = PVE::RADOS->new();
-
+
eval {
my $bindata = $rados->mon_command({ prefix => 'osd getcrushmap', format => 'plain' });
PVE::Tools::file_set_contents($mapfile, $bindata);
unlink $mapdata;
die $err if $err;
-
+
return $txt;
}});
__PACKAGE__->register_method({
- name => 'log',
- path => 'log',
+ name => 'log',
+ path => 'log',
method => 'GET',
description => "Read ceph log",
proxyto => 'node',
},
protected => 1,
parameters => {
- additionalProperties => 0,
+ additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
start => {
},
returns => {
type => 'array',
- items => {
+ items => {
type => "object",
properties => {
n => {
my ($count, $lines) = PVE::Tools::dump_logfile($logfile, $param->{start}, $param->{limit});
$rpcenv->set_result_attrib('total', $count);
-
- return $lines;
+
+ return $lines;
}});