]> git.proxmox.com Git - pve-cluster.git/commitdiff
add API class for cluster configuration
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 29 Nov 2016 10:51:38 +0000 (11:51 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 29 Nov 2016 10:54:56 +0000 (11:54 +0100)
Read-only for now. addnode/delnode implementation will follow.

data/PVE/API2/ClusterConfig.pm [new file with mode: 0644]
data/PVE/Makefile.am

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
new file mode 100644 (file)
index 0000000..ab807bd
--- /dev/null
@@ -0,0 +1,93 @@
+package PVE::API2::ClusterConfig;
+
+use strict;
+use warnings;
+use PVE::Tools;
+use PVE::SafeSyslog;
+use PVE::RESTHandler;
+use PVE::RPCEnvironment;
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::Cluster;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    description => "Directory index.",
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => {
+       type => 'array',
+       items => {
+           type => "object",
+           properties => {},
+       },
+       links => [ { rel => 'child', href => "{name}" } ],
+    },
+    code => sub {
+       my ($param) = @_;
+
+       my $result = [
+           { name => 'nodes' },
+           { name => 'totem' },
+           ];
+
+       return $result;
+    }});
+
+__PACKAGE__->register_method({
+    name => 'nodes',
+    path => 'nodes',
+    method => 'GET',
+    description => "Corosync node list.",
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => {
+       type => 'array',
+       items => {
+           type => "object",
+           properties => {
+               node => { type => 'string' },
+           },
+       },
+       links => [ { rel => 'child', href => "{node}" } ],
+    },
+    code => sub {
+       my ($param) = @_;
+
+
+       my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
+       my $nodelist = PVE::Cluster::corosync_nodelist($conf);
+
+       return PVE::RESTHandler::hash_to_array($nodelist, 'node');
+    }});
+
+__PACKAGE__->register_method({
+    name => 'totem',
+    path => 'totem',
+    method => 'GET',
+    description => "Get corosync totem protocol settings.",
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => {
+       type => "object",
+       properties => {},
+    },
+    code => sub {
+       my ($param) = @_;
+
+
+       my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
+
+       return PVE::Cluster::corosync_totem_config($conf);
+    }});
+
+1;
index b284e7f1639b386263abc84fe97af9a146bd7017..0d89e63ba13f82b63abf9c95467c381b4a212d9a 100644 (file)
@@ -33,6 +33,9 @@ noinst_DATA = pvecm.bash-completion
 cliclass_DATA = CLI/pvecm.pm
 cliclassdir = $(PERL_VENDORLIB)/PVE/CLI
 
+apiclass_DATA = API2/ClusterConfig.pm
+apiclassdir = $(PERL_VENDORLIB)/PVE/API2
+
 install-exec-hook: pvecm.bash-completion
        perl -I.. -T -e "use PVE::CLI::pvecm; PVE::CLI::pvecm->verify_api();"
        install -m 0644 -D pvecm.bash-completion ${DESTDIR}/usr/share/bash-completion/completions/pvecm