]>
Commit | Line | Data |
---|---|---|
963c06bb DM |
1 | package PVE::API2::ClusterConfig; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
b6973a89 | 5 | |
963c06bb DM |
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; | |
b6973a89 | 12 | use PVE::Corosync; |
963c06bb DM |
13 | |
14 | use base qw(PVE::RESTHandler); | |
15 | ||
16 | __PACKAGE__->register_method({ | |
17 | name => 'index', | |
18 | path => '', | |
19 | method => 'GET', | |
20 | description => "Directory index.", | |
fb7c665a EK |
21 | permissions => { |
22 | check => ['perm', '/', [ 'Sys.Audit' ]], | |
23 | }, | |
963c06bb DM |
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.", | |
fb7c665a EK |
52 | permissions => { |
53 | check => ['perm', '/', [ 'Sys.Audit' ]], | |
54 | }, | |
963c06bb DM |
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'); | |
b6973a89 | 74 | my $nodelist = PVE::Corosync::nodelist($conf); |
963c06bb DM |
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.", | |
fb7c665a EK |
84 | permissions => { |
85 | check => ['perm', '/', [ 'Sys.Audit' ]], | |
86 | }, | |
963c06bb DM |
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 | ||
b6973a89 | 101 | return PVE::Corosync::totem_config($conf); |
963c06bb DM |
102 | }}); |
103 | ||
104 | 1; |