description => "CPU utilization (when type in node,qemu,lxc).",
type => 'number',
optional => 1,
+ minimum => 0,
renderer => 'fraction_as_percentage',
},
maxcpu => {
description => "Number of available CPUs (when type in node,qemu,lxc).",
type => 'number',
optional => 1,
+ minimum => 0,
},
mem => {
description => "Used memory in bytes (when type in node,qemu,lxc).",
- type => 'string',
+ type => 'integer',
optional => 1,
renderer => 'bytes',
+ minimum => 0,
},
maxmem => {
description => "Number of available memory in bytes (when type in node,qemu,lxc).",
},
disk => {
description => "Used disk space in bytes (when type in storage), used root image spave for VMs (type in qemu,lxc).",
- type => 'string',
+ type => 'integer',
optional => 1,
renderer => 'bytes',
+ minimum => 0,
},
maxdisk => {
description => "Storage size in bytes (when type in storage), root image size for VMs (type in qemu,lxc).",
type => 'integer',
optional => 1,
renderer => 'bytes',
+ minimum => 0,
},
content => {
description => "Allowed storage content types (when type == storage).",
type => 'string',
optional => 1,
},
+ vmid => {
+ description => "The numerical vmid (when type in qemu,lxc).",
+ type => 'integer',
+ optional => 1,
+ minimum => 1,
+ },
},
},
},
my $authuser = $rpcenv->get_user();
my $tlist = PVE::Cluster::get_tasklist();
-
- my $res = [];
-
- return $res if !$tlist;
+ return [] if !$tlist;
my $all = $rpcenv->check($authuser, "/", [ 'Sys.Audit' ], 1);
+ my $res = [];
foreach my $task (@$tlist) {
if (PVE::AccessControl::pve_verify_tokenid($task->{user}, 1)) {
($task->{user}, $task->{tokenid}) = PVE::AccessControl::split_tokenid($task->{user});
# fake entry for local node if no cluster defined
my $pmxcfs = ($clinfo && $clinfo->{version}) ? 1 : 0; # pmxcfs online ?
- my $subinfo = PVE::INotify::read_file('subscription');
+ my $subinfo = PVE::API2::Subscription::read_etc_subscription();
my $sublevel = $subinfo->{level} || '';
return [{
raise_param_exc({ vmid => "VM $vmid already exists" });
}
- for (my $i = 100; $i < 10000; $i++) {
+ my $dc_conf = PVE::Cluster::cfs_read_file('datacenter.cfg');
+ my $next_id = $dc_conf->{'next-id'} // {};
+
+ my $lower = $next_id->{lower} // 100;
+ my $upper = $next_id->{upper} // (1000 * 1000); # note, lower than the schema-maximum
+
+ for (my $i = $lower; $i < $upper; $i++) {
return $i if !defined($idlist->{$i});
}
- die "unable to get any free VMID\n";
+ die "unable to get any free VMID in range [$lower, $upper]\n";
}});
1;