]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/PVE/DataCenterConfig.pm
datacenter config: add tag-style property
[pve-cluster.git] / data / PVE / DataCenterConfig.pm
index 6fc67f150fd1ecb2145ad72583ee924d9495e0dd..532e5e509965c6b6880b60d1d04748530a0ad3bb 100644 (file)
@@ -51,6 +51,25 @@ my $ha_format = {
     }
 };
 
+my $next_id_format = {
+    lower => {
+       type => 'integer',
+       description => "Lower, inclusive boundary for free next-id API range.",
+       min => 100,
+       max => 1000 * 1000 * 1000 - 1,
+       default => 100,
+       optional => 1,
+    },
+    upper => {
+       type => 'integer',
+       description => "Upper, exclusive boundary for free next-id API range.",
+       min => 100,
+       max => 1000 * 1000 * 1000,
+       default => 1000 * 1000, # lower than the maximum on purpose
+       optional => 1,
+    },
+};
+
 my $u2f_format = {
     appid => {
        type => 'string',
@@ -88,11 +107,17 @@ my $webauthn_format = {
     id => {
        type => 'string',
        description =>
-           'Relying part ID. Must be the domain name without protocol, port or location.'
+           'Relying party ID. Must be the domain name without protocol, port or location.'
            .' Changing this *will* break existing credentials.',
        format_description => 'DOMAINNAME',
        optional => 1,
     },
+    'allow-subdomains' => {
+       type => 'boolean',
+       description => 'Whether to allow the origin to be a subdomain, rather than the exact URL.',
+       optional => 1,
+       default => 1,
+    },
 };
 
 PVE::JSONSchema::register_format('mac-prefix', \&pve_verify_mac_prefix);
@@ -106,6 +131,29 @@ sub pve_verify_mac_prefix {
     return $mac_prefix;
 }
 
+my $COLOR_RE = '[0-9a-fA-F]{6}';
+my $TAG_COLOR_OVERRIDE_RE = "(?:${PVE::JSONSchema::PVE_TAG_RE}:${COLOR_RE}(?:\:${COLOR_RE})?)";
+
+my $tag_style_format = {
+    'shape' => {
+       optional => 1,
+       type => 'string',
+       enum => ['full', 'circle', 'dense', 'none'],
+       default => 'circle',
+       description => "Tag shape for the web ui tree. 'full' draws the full tag. "
+           ."'circle' draws only a circle with the background color. "
+           ."'dense' only draws a small rectancle (useful when many tags are assigned to each guest)."
+           ."'none' disables showing the tags.",
+    },
+    'color-map' => {
+       optional => 1,
+       type => 'string',
+       pattern => "${TAG_COLOR_OVERRIDE_RE}(?:\;$TAG_COLOR_OVERRIDE_RE)*",
+       typetext => '<tag>:<hex-color>[:<hex-color-for-text>][;<tag>=...]',
+       description => "Manual color mapping for tags (semicolon separated).",
+    },
+};
+
 my $datacenter_schema = {
     type => "object",
     additionalProperties => 0,
@@ -150,6 +198,7 @@ my $datacenter_schema = {
            description => "Specify external http proxy which is used for downloads (example: 'http://username:password\@host:port/')",
            pattern => "http://.*",
        },
+       # FIXME: remove with 8.0 (add check to pve7to8!), merged into "migration" since 4.3
        migration_unsecure => {
            optional => 1,
            type => 'boolean',
@@ -157,6 +206,12 @@ my $datacenter_schema = {
              "For secure private networks you can disable it to speed up " .
              "migration. Deprecated, use the 'migration' property instead!",
        },
+       'next-id' => {
+           optional => 1,
+           type => 'string',
+           format => $next_id_format,
+           description => "Control the range for the free VMID auto-selection pool.",
+       },
        migration => {
            optional => 1,
            type => 'string', format => $migration_format,
@@ -165,7 +220,9 @@ my $datacenter_schema = {
        console => {
            optional => 1,
            type => 'string',
-           description => "Select the default Console viewer. You can either use the builtin java applet (VNC; deprecated and maps to html5), an external virt-viewer comtatible application (SPICE), an HTML5 based vnc viewer (noVNC), or an HTML5 based console client (xtermjs). If the selected viewer is not available (e.g. SPICE not activated for the VM), the fallback is noVNC.",
+           description => "Select the default Console viewer. You can either use the builtin java"
+               ." applet (VNC; deprecated and maps to html5), an external virt-viewer comtatible application (SPICE), an HTML5 based vnc viewer (noVNC), or an HTML5 based console client (xtermjs). If the selected viewer is not available (e.g. SPICE not activated for the VM), the fallback is noVNC.",
+           # FIXME: remove 'applet' with 8.0 (add pve7to8 check!)
            enum => ['applet', 'vv', 'html5', 'xtermjs'],
        },
        email_from => {
@@ -222,6 +279,12 @@ my $datacenter_schema = {
            maxLength => 64 * 1024,
            optional => 1,
        },
+       'tag-style' => {
+           optional => 1,
+           type => 'string',
+           description => "Tag style options.",
+           format => $tag_style_format,
+       },
     },
 };
 
@@ -236,7 +299,7 @@ sub parse_datacenter_config {
     # description may be comment or key-value pair (or both)
     my $comment = '';
     for my $line (split(/\n/, $raw)) {
-       if ($line =~ /^\#(.*)\s*$/) {
+       if ($line =~ /^\#(.*)$/) {
            $comment .= PVE::Tools::decode_text($1) . "\n";
        }
     }
@@ -250,6 +313,10 @@ sub parse_datacenter_config {
        $res->{migration} = parse_property_string($migration_format, $migration);
     }
 
+    if (my $next_id = $res->{'next-id'}) {
+       $res->{'next-id'} = parse_property_string($next_id_format, $next_id);
+    }
+
     if (my $ha = $res->{ha}) {
        $res->{ha} = parse_property_string($ha_format, $ha);
     }
@@ -262,6 +329,10 @@ sub parse_datacenter_config {
        $res->{webauthn} = parse_property_string($webauthn_format, $webauthn);
     }
 
+    if (my $tag_style = $res->{'tag-style'}) {
+       $res->{'tag-style'} = parse_property_string($tag_style_format, $tag_style);
+    }
+
     # for backwards compatibility only, new migration property has precedence
     if (defined($res->{migration_unsecure})) {
        if (defined($res->{migration}->{type})) {
@@ -298,6 +369,17 @@ sub write_datacenter_config {
        $cfg->{migration} = PVE::JSONSchema::print_property_string($migration, $migration_format);
     }
 
+    if (defined(my $next_id = $cfg->{'next-id'})) {
+        $next_id = parse_property_string($next_id_format, $next_id) if !ref($next_id);
+
+       my $lower = int($next_id->{lower} // $next_id_format->{lower}->{default});
+       my $upper = int($next_id->{upper} // $next_id_format->{upper}->{default});
+
+       die "lower ($lower) <= upper ($upper) boundary rule broken\n" if $lower > $upper;
+
+       $cfg->{'next-id'} = PVE::JSONSchema::print_property_string($next_id, $next_id_format);
+    }
+
     if (ref(my $ha = $cfg->{ha})) {
        $cfg->{ha} = PVE::JSONSchema::print_property_string($ha, $ha_format);
     }
@@ -310,6 +392,10 @@ sub write_datacenter_config {
        $cfg->{webauthn} = PVE::JSONSchema::print_property_string($webauthn, $webauthn_format);
     }
 
+    if (ref(my $tag_style = $cfg->{'tag-style'})) {
+       $cfg->{'tag-style'} = PVE::JSONSchema::print_property_string($tag_style, $tag_style_format);
+    }
+
     my $comment = '';
     # add description as comment to top of file
     my $description = $cfg->{description} || '';