]> git.proxmox.com Git - pve-common.git/commitdiff
SectionConfig: allow to get class specific updateSchema()
authorDietmar Maurer <dietmar@proxmox.com>
Sun, 19 Feb 2017 10:17:34 +0000 (11:17 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 19 Feb 2017 10:17:34 +0000 (11:17 +0100)
Useful when you have different section types, and you want to have
separate update API methods.

src/PVE/SectionConfig.pm

index a6301e262598d0ee7886144ec104cb51301e5b24..6273afa35a22cb09ca14d2f010f5aad8b96dba47 100644 (file)
@@ -104,7 +104,7 @@ sub createSchema {
 }
 
 sub updateSchema {
 }
 
 sub updateSchema {
-    my ($class) = @_;
+    my ($class, $single_class) = @_;
 
     my $pdata = $class->private();
     my $propertyList = $pdata->{propertyList};
 
     my $pdata = $class->private();
     my $propertyList = $pdata->{propertyList};
@@ -112,8 +112,15 @@ sub updateSchema {
 
     my $props = {};
 
 
     my $props = {};
 
+    my $filter_type = $class->type() if $single_class;
+
     foreach my $p (keys %$propertyList) {
        next if $p eq 'type';
     foreach my $p (keys %$propertyList) {
        next if $p eq 'type';
+
+       my $copts = $class->options();
+
+       next if defined($filter_type) && !defined($copts->{$p});
+
        if (!$propertyList->{$p}->{optional}) {
            $props->{$p} = $propertyList->{$p};
            next;
        if (!$propertyList->{$p}->{optional}) {
            $props->{$p} = $propertyList->{$p};
            next;
@@ -121,7 +128,6 @@ sub updateSchema {
 
        my $modifyable = 0;
 
 
        my $modifyable = 0;
 
-       my $copts = $class->options();
        $modifyable = 1 if defined($copts->{$p}) && !$copts->{$p}->{fixed};
 
        foreach my $t (keys %$plugins) {
        $modifyable = 1 if defined($copts->{$p}) && !$copts->{$p}->{fixed};
 
        foreach my $t (keys %$plugins) {