]>
git.proxmox.com Git - pmg-api.git/blob - PMG/API2/ClusterConfig.pm
1 package PMG
::API2
::ClusterConfig
;
8 use PVE
::Tools
qw(extract_param);
9 use HTTP
::Status
qw(:constants);
10 use Storable
qw(dclone);
11 use PVE
::JSONSchema
qw(get_standard_option);
15 use PMG
::ClusterConfig
;
17 use base
qw(PVE::RESTHandler);
19 __PACKAGE__-
>register_method({
23 description
=> "Cluster node index.",
24 # alway read local file
26 additionalProperties
=> 0,
29 permissions
=> { check
=> [ 'admin' ] },
35 cid
=> { type
=> 'integer' },
38 links
=> [ { rel
=> 'child', href
=> "{cid}" } ],
43 my $cfg = PVE
::INotify
::read_file
('cluster.conf');
45 return PVE
::RESTHandler
::hash_to_array
($cfg->{ids
}, 'cid');
48 __PACKAGE__-
>register_method({
49 name
=> 'create_master',
52 description
=> "Create initial cluster config with current node as master.",
53 # alway read local file
55 additionalProperties
=> 0,
58 returns
=> { type
=> 'null' },
63 my $cfg = PMG
::ClusterConfig-
>new();
65 die "cluster alreayd defined\n" if scalar(keys %{$cfg->{ids
}});
67 my $info = PMG
::Cluster
::read_local_cluster_info
();
69 $info->{type
} = 'master';
72 $cfg->{ids
}->{$info->{maxcid
}} = $info;
77 PMG
::ClusterConfig
::lock_config
($code, "create cluster failed");