[pve-devel] [PATCH manager v10 01/13] api: /cluster/resources: add tags to returned properties

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Nov 16 09:02:22 CET 2022


would adapt this a bit, see inline, but no hard feelings

Am 15/11/2022 um 14:02 schrieb Dominik Csapak:
> by querying 'lock' and 'tags' with 'get_guest_config_properties'
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  PVE/API2/Cluster.pm | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index 49e319a5c..34a6e08cd 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -371,7 +371,8 @@ __PACKAGE__->register_method({
>  
>  	# we try to generate 'numbers' by using "$X + 0"
>  	if (!$param->{type} || $param->{type} eq 'vm') {
> -	    my $locked_vms = PVE::Cluster::get_guest_config_property('lock');
> +	    my $prop_list = [qw(lock tags)];
> +	    my $props = PVE::Cluster::get_guest_config_properties($prop_list);

props is a bit generic and having the prop_list here and below adds not much
value IMO, maybe rather here:

my $extra_guest_info = PVE::Cluster::get_guest_config_properties(['lock', 'tags']);

>  
>  	    for my $vmid (sort keys %$idlist) {
>  
> @@ -403,8 +404,10 @@ __PACKAGE__->register_method({
>  		# only skip now to next to ensure that the pool stats above are filled, if eligible
>  		next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
>  
> -		if (defined(my $lock = $locked_vms->{$vmid}->{lock})) {
> -		    $entry->{lock} = $lock;
> +		for my $prop (@$prop_list) {

and then here:

for my $key (keys $extra_guest_info->{$vmid}->%) {
    my $value = $extra_guest_info->{$vmid}->{$key} // next;
    $entry->{$prop} = $extra_guest_info->{$vmid}->{$key};
}

> +		    if (defined(my $value = $props->{$vmid}->{$prop})) {
> +			$entry->{$prop} = $value;
> +		    }
>  		}
>  
>  		if (defined($entry->{pool}) &&






More information about the pve-devel mailing list