]> git.proxmox.com Git - pve-cluster.git/blob - data/PVE/API2/ClusterConfig.pm
corosync config parser: move to hash format
[pve-cluster.git] / data / PVE / API2 / ClusterConfig.pm
1 package PVE::API2::ClusterConfig;
2
3 use strict;
4 use warnings;
5
6 use PVE::Tools;
7 use PVE::SafeSyslog;
8 use PVE::RESTHandler;
9 use PVE::RPCEnvironment;
10 use PVE::JSONSchema qw(get_standard_option);
11 use PVE::Cluster;
12 use PVE::Corosync;
13
14 use base qw(PVE::RESTHandler);
15
16 __PACKAGE__->register_method({
17 name => 'index',
18 path => '',
19 method => 'GET',
20 description => "Directory index.",
21 permissions => {
22 check => ['perm', '/', [ 'Sys.Audit' ]],
23 },
24 parameters => {
25 additionalProperties => 0,
26 properties => {},
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 => 'nodes' },
41 { name => 'totem' },
42 ];
43
44 return $result;
45 }});
46
47 __PACKAGE__->register_method({
48 name => 'nodes',
49 path => 'nodes',
50 method => 'GET',
51 description => "Corosync node list.",
52 permissions => {
53 check => ['perm', '/', [ 'Sys.Audit' ]],
54 },
55 parameters => {
56 additionalProperties => 0,
57 properties => {},
58 },
59 returns => {
60 type => 'array',
61 items => {
62 type => "object",
63 properties => {
64 node => { type => 'string' },
65 },
66 },
67 links => [ { rel => 'child', href => "{node}" } ],
68 },
69 code => sub {
70 my ($param) = @_;
71
72
73 my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
74 my $nodelist = PVE::Corosync::nodelist($conf);
75
76 return PVE::RESTHandler::hash_to_array($nodelist, 'node');
77 }});
78
79 __PACKAGE__->register_method({
80 name => 'totem',
81 path => 'totem',
82 method => 'GET',
83 description => "Get corosync totem protocol settings.",
84 permissions => {
85 check => ['perm', '/', [ 'Sys.Audit' ]],
86 },
87 parameters => {
88 additionalProperties => 0,
89 properties => {},
90 },
91 returns => {
92 type => "object",
93 properties => {},
94 },
95 code => sub {
96 my ($param) = @_;
97
98
99 my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
100
101 my $totem_cfg = $conf->{main}->{totem};
102
103 return $totem_cfg;
104 }});
105
106 1;