]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/config.pm
a5171fbf8af43753ae268da500cec413ab484d7c
1 package PVE
::APIClient
::Commands
::config
;
7 use PVE
::APIClient
::Helpers
;
8 use PVE
::APIClient
::JSONSchema
qw(get_standard_option);
9 use PVE
::APIClient
::Tools
qw(extract_param);
10 use PVE
::APIClient
::Config
;
12 use PVE
::APIClient
::CLIHandler
;
14 use base
qw(PVE::APIClient::CLIHandler);
16 my $list_return_props = { %{PVE
::APIClient
::DefaultsConfig-
>updateSchema(1)->{properties
}} };
17 delete $list_return_props->{delete};
19 __PACKAGE__-
>register_method ({
23 description
=> "Dump default configuration.",
25 additionalProperties
=> 0,
29 properties
=> $list_return_props,
33 my $config = PVE
::APIClient
::Config-
>load();
35 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
37 $defaults->{digest
} = $config->{digest
};
42 __PACKAGE__-
>register_method ({
46 description
=> "Update a remote configuration.",
47 parameters
=> PVE
::APIClient
::DefaultsConfig-
>updateSchema(1),
48 returns
=> { type
=> 'null'},
52 my $digest = extract_param
($param, 'digest');
53 my $delete = extract_param
($param, 'delete');
56 my $config = PVE
::APIClient
::Config-
>load();
58 PVE
::APIClient
::Tools
::assert_if_modified
($config->{digest
}, $digest);
60 my $defaults = PVE
::APIClient
::Config-
>get_defaults($config);
62 my $plugin = PVE
::APIClient
::Config-
>lookup('defaults');
63 my $opts = $plugin->check_config('defaults', $param, 0, 1);
65 foreach my $k (%$opts) {
66 $defaults->{$k} = $opts->{$k};
70 my $options = $plugin->private()->{options
}->{'defaults'};
71 foreach my $k (PVE
::APIClient
::Tools
::split_list
($delete)) {
72 my $d = $options->{$k} ||
73 die "no such option '$k'\n";
74 die "unable to delete required option '$k'\n"
76 die "unable to delete fixed option '$k'\n"
78 delete $defaults->{$k};
82 PVE
::APIClient
::Config-
>save($config);
85 PVE
::APIClient
::Config-
>lock_config(undef, $code);
92 set
=> [ __PACKAGE__
, 'set',],
93 list
=> [__PACKAGE__
, 'list', undef, undef, sub { PVE
::APIClient
::Helpers
::print_result
(@_);}],