use strict;
use warnings;
-use PVE::JSONSchema;
+use PVE::JSONSchema qw(parse_property_string);
use PVE::Tools;
use PVE::Cluster;
}
};
+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, inclusive boundary for free next-id API range.",
+ min => 100,
+ max => 1000 * 1000 * 1000 - 1,
+ default => 1000 * 1000, # lower than the maximum on purpose
+ optional => 1,
+ },
+};
+
my $u2f_format = {
appid => {
type => 'string',
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',
"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,
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 => {
# description may be comment or key-value pair (or both)
my $comment = '';
- my @lines = split(/\n/, $raw);
- foreach my $line (@lines) {
- if ($line =~ /^\#(.*)\s*$/) {
+ for my $line (split(/\n/, $raw)) {
+ if ($line =~ /^\#(.*)$/) {
$comment .= PVE::Tools::decode_text($1) . "\n";
}
}
$res->{description} = $comment;
-
if (my $migration = $res->{migration}) {
- $res->{migration} = PVE::JSONSchema::parse_property_string($migration_format, $migration);
+ $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} = PVE::JSONSchema::parse_property_string($ha_format, $ha);
+ $res->{ha} = parse_property_string($ha_format, $ha);
}
if (my $u2f = $res->{u2f}) {
- $res->{u2f} = PVE::JSONSchema::parse_property_string($u2f_format, $u2f);
+ $res->{u2f} = parse_property_string($u2f_format, $u2f);
}
if (my $webauthn = $res->{webauthn}) {
- $res->{webauthn} = PVE::JSONSchema::parse_property_string($webauthn_format, $webauthn);
+ $res->{webauthn} = parse_property_string($webauthn_format, $webauthn);
}
# for backwards compatibility only, new migration property has precedence
$cfg->{console} = 'html5';
}
- if (ref($cfg->{migration})) {
- my $migration = $cfg->{migration};
+ if (ref(my $migration = $cfg->{migration})) {
$cfg->{migration} = PVE::JSONSchema::print_property_string($migration, $migration_format);
}
- if (ref($cfg->{ha})) {
- my $ha = $cfg->{ha};
+ 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" 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);
}
- if (ref($cfg->{u2f})) {
- my $u2f = $cfg->{u2f};
+ if (ref(my $u2f = $cfg->{u2f})) {
$cfg->{u2f} = PVE::JSONSchema::print_property_string($u2f, $u2f_format);
}
- if (ref($cfg->{webauthn})) {
- my $webauthn = $cfg->{webauthn};
+ if (ref(my $webauthn = $cfg->{webauthn})) {
$cfg->{webauthn} = PVE::JSONSchema::print_property_string($webauthn, $webauthn_format);
}
return $comment . "\n" . $dump;
}
-PVE::Cluster::cfs_register_file('datacenter.cfg',
- \&parse_datacenter_config,
- \&write_datacenter_config);
+PVE::Cluster::cfs_register_file(
+ 'datacenter.cfg',
+ \&parse_datacenter_config,
+ \&write_datacenter_config,
+);
1;