]> git.proxmox.com Git - pve-manager.git/blob - PVE/API2/Ceph/Cfg.pm
api: ceph: add ceph/cfg path, deprecate ceph/config and ceph/configdb
[pve-manager.git] / PVE / API2 / Ceph / Cfg.pm
1 package PVE::API2::Ceph::Cfg;
2
3 use strict;
4 use warnings;
5
6 use PVE::Ceph::Tools;
7 use PVE::JSONSchema qw(get_standard_option);
8 use PVE::RADOS;
9 use PVE::Tools qw(file_get_contents);
10
11 use base qw(PVE::RESTHandler);
12
13 __PACKAGE__->register_method ({
14 name => 'index',
15 path => '',
16 method => 'GET',
17 description => "Directory index.",
18 permissions => { user => 'all' },
19 permissions => {
20 check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
21 },
22 parameters => {
23 additionalProperties => 0,
24 properties => {
25 node => get_standard_option('pve-node'),
26 },
27 },
28 returns => {
29 type => 'array',
30 items => {
31 type => "object",
32 properties => {},
33 },
34 links => [ { rel => 'child', href => "{name}" } ],
35 },
36 code => sub {
37 my ($param) = @_;
38
39 my $result = [
40 { name => 'raw' },
41 { name => 'db' },
42 ];
43
44 return $result;
45 }});
46
47 __PACKAGE__->register_method ({
48 name => 'raw',
49 path => 'raw',
50 method => 'GET',
51 proxyto => 'node',
52 permissions => {
53 check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
54 },
55 description => "Get the Ceph configuration file.",
56 parameters => {
57 additionalProperties => 0,
58 properties => {
59 node => get_standard_option('pve-node'),
60 },
61 },
62 returns => { type => 'string' },
63 code => sub {
64 my ($param) = @_;
65
66 PVE::Ceph::Tools::check_ceph_inited();
67
68 my $path = PVE::Ceph::Tools::get_config('pve_ceph_cfgpath');
69 return file_get_contents($path);
70
71 }});
72
73 __PACKAGE__->register_method ({
74 name => 'db',
75 path => 'db',
76 method => 'GET',
77 proxyto => 'node',
78 protected => 1,
79 permissions => {
80 check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
81 },
82 description => "Get the Ceph configuration database.",
83 parameters => {
84 additionalProperties => 0,
85 properties => {
86 node => get_standard_option('pve-node'),
87 },
88 },
89 returns => {
90 type => 'array',
91 items => {
92 type => 'object',
93 properties => {
94 section => { type => "string", },
95 name => { type => "string", },
96 value => { type => "string", },
97 level => { type => "string", },
98 'can_update_at_runtime' => { type => "boolean", },
99 mask => { type => "string" },
100 },
101 },
102 },
103 code => sub {
104 my ($param) = @_;
105
106 PVE::Ceph::Tools::check_ceph_inited();
107
108 my $rados = PVE::RADOS->new();
109 my $res = $rados->mon_command( { prefix => 'config dump', format => 'json' });
110 foreach my $entry (@$res) {
111 $entry->{can_update_at_runtime} = $entry->{can_update_at_runtime}? 1 : 0; # JSON::true/false -> 1/0
112 }
113
114 return $res;
115 }});