]>
git.proxmox.com Git - pve-ha-manager.git/blob - src/PVE/API2/HA/Groups.pm
1 package PVE
::API2
::HA
::Groups
;
7 use PVE
::Tools
qw(extract_param);
8 use PVE
::Cluster
qw(cfs_read_file cfs_write_file);
10 use HTTP
::Status
qw(:constants);
11 use Storable
qw(dclone);
12 use PVE
::JSONSchema
qw(get_standard_option);
13 use PVE
::RPCEnvironment
;
17 use base
qw(PVE::RESTHandler);
19 # fixme: use cfs_read_file
21 my $ha_groups_config = "/etc/pve/ha/groups.cfg";
23 # fixme: fix permissions
25 my $api_copy_config = sub {
28 my $scfg = dclone
($cfg->{ids
}->{$sid});
29 $scfg->{group
} = $sid;
30 $scfg->{digest
} = $cfg->{digest
};
35 __PACKAGE__-
>register_method ({
39 description
=> "Get HA groups.",
41 additionalProperties
=> 0,
48 properties
=> { group
=> { type
=> 'string'} },
50 links
=> [ { rel
=> 'child', href
=> "{group}" } ],
57 $raw = PVE
::Tools
::file_get_contents
($ha_groups_config)
58 if -f
$ha_groups_config;
60 my $cfg = PVE
::HA
::Config
::parse_groups_config
($ha_groups_config, $raw);
63 foreach my $sid (keys %{$cfg->{ids
}}) {
64 my $scfg = &$api_copy_config($cfg, $sid);
65 next if $scfg->{type
} ne 'group'; # should not happen