]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/API2/NodeConfig.pm
1 package PMG
::API2
::NodeConfig
;
6 use PVE
::JSONSchema
qw(get_standard_option);
7 use PVE
::Tools
qw(extract_param);
11 use base
qw(PVE::RESTHandler);
13 __PACKAGE__-
>register_method ({
17 description
=> "Get node configuration options.",
20 permissions
=> { check
=> [ 'admin', 'audit' ] },
22 additionalProperties
=> 0,
24 node
=> get_standard_option
('pve-node'),
27 returns
=> PMG
::NodeConfig
::acme_config_schema
({
30 description
=> 'Prevent changes if current configuration file has different SHA1 digest.'
31 .' This can be used to prevent concurrent modifications.',
39 return PMG
::NodeConfig
::load_config
();
42 __PACKAGE__-
>register_method ({
46 description
=> "Set node configuration options.",
49 permissions
=> { check
=> [ 'admin', 'audit' ] },
50 parameters
=> PMG
::NodeConfig
::acme_config_schema
({
52 type
=> 'string', format
=> 'pve-configid-list',
53 description
=> "A list of settings you want to delete.",
58 description
=> 'Prevent changes if current configuration file has different SHA1 digest.'
59 .' This can be used to prevent concurrent modifications.',
63 node
=> get_standard_option
('pve-node'),
65 returns
=> { type
=> "null" },
69 my $node = extract_param
($param, 'node');
70 my $delete = extract_param
($param, 'delete');
71 my $digest = extract_param
($param, 'digest');
73 PMG
::NodeConfig
::lock_config
(sub {
74 my $conf = PMG
::NodeConfig
::load_config
();
76 PVE
::Tools
::assert_if_modified
($digest, delete $conf->{digest
});
78 foreach my $opt (PVE
::Tools
::split_list
($delete)) {
81 foreach my $opt (keys %$param) {
82 $conf->{$opt} = $param->{$opt};
85 # validate the acme config (check for duplicates)
86 PMG
::NodeConfig
::get_acme_conf
($conf);
88 PMG
::NodeConfig
::write_config
($conf);