public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Fabian Ebner <f.ebner@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v3 manager 2/4] api: vzdump: add call to get currently configured vzdump defaults
Date: Fri, 2 Apr 2021 14:58:39 +0200	[thread overview]
Message-ID: <89ccc8a8-9337-ae32-2e97-e65211e6eaeb@proxmox.com> (raw)
In-Reply-To: <a40f345c-31cd-f60e-81d7-283cd9a69a39@proxmox.com>

On 02.04.21 14:27, Fabian Ebner wrote:
> Am 01.04.21 um 15:40 schrieb Thomas Lamprecht:
>> On 11.03.21 10:22, Fabian Ebner wrote:
>>> +    user => 'all',
>>> +    },
>>> +    proxyto => 'node',
>>> +    parameters => {
>>> +    additionalProperties => 0,
>>> +    properties => {
>>> +        node => get_standard_option('pve-node'),
>>> +        storage => get_standard_option('pve-storage-id', { optional => 1 }),
>>> +    },
>>> +    },
>>> +    returns => {
>>> +    type => 'object',
>>> +    additionalProperties => 0,
>>> +    properties => PVE::VZDump::Common::json_config_properties(),
>>
>> above may suggest that all those properties are returned, but we delete some
>> out flat, so even if one would access this as root@pam they won't get all of
>> those and may get confused due to API schema/return value mismatch.
>>
>> Maybe we could derive a hash from above list at module scope, and delete those
>> keys that never will be returned. That list could also be reused below 
for
>> filtering out those unwanted keys too then.
>>
> 
> The only key that is always dropped is the deprecated 'size' key. For privileged users, all others are returned. And the schema says that all properties are optional. We could create a new hash and drop the 'optional' 
for those with a default value that are never dropped, but not sure if that's worth it...

hmm, yeah in that case it's probably not worth it...

> 
>>> +    },
>>> +    code => sub {
>>> +    my ($param) = @_;
>>> +
>>> +    my $node = extract_param($param, 'node');
>>> +    my $storage = extract_param($param, 'storage');
>>> +
>>> +    my $rpcenv = PVE::RPCEnvironment::get();
>>> +    my $authuser = $rpcenv->get_user();
>>> +
>>> +    my $res = PVE::VZDump::read_vzdump_defaults();
>>> +
>>> +    $res->{storage} = $storage if defined($storage);
>>> +
>>> +    if (!defined($res->{dumpdir}) && !defined($res->{storage})) {
>>> +        $res->{storage} = 'local';
>>> +    }
>>> +
>>> +    if (defined($res->{storage})) {
>>> +        $rpcenv->check_any(
>>> +        $authuser,
>>> +        "/storage/$res->{storage}",
>>> +        ['Datastore.Audit', 'Datastore.AllocateSpace'],
>>> +        );
>>> +
>>> +        my $info = PVE::VZDump::storage_info($res->{storage});
>>> +        foreach my $key (qw(dumpdir prune-backups)) {
>>
>> style nit, for new code use `for`, `foreach` has no additional value/functionality
>> over `for` since a long time (if ever, actually not too sure from top of my head).
>>
> 
> Will do, but might be worth updating the style guide:
> "use either of foreach or for when looping over a list of elements."
> 
> https://pve.proxmox.com/wiki/Perl_Style_Guide#Perl_syntax_choices

good catch, done!




  reply	other threads:[~2021-04-02 12:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11  9:22 [pve-devel] [PATCH v3 manager 1/4] vzdump: storage info: move out activate storage call Fabian Ebner
2021-03-11  9:22 ` [pve-devel] [PATCH v3 manager 2/4] api: vzdump: add call to get currently configured vzdump defaults Fabian Ebner
2021-04-01 13:40   ` Thomas Lamprecht
2021-04-02 12:27     ` Fabian Ebner
2021-04-02 12:58       ` Thomas Lamprecht [this message]
2021-03-11  9:22 ` [pve-devel] [PATCH v3 manager 3/4] ui: backup: fill in some of the " Fabian Ebner
2021-03-11  9:22 ` [pve-devel] [PATCH v3 manager 4/4] fix #2745: ui: backup: allow specifying remove parameter for manual backup Fabian Ebner
2021-04-01 13:25 ` [pve-devel] applied: [PATCH v3 manager 1/4] vzdump: storage info: move out activate storage call Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89ccc8a8-9337-ae32-2e97-e65211e6eaeb@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal