Using a dot (.) as a VMID will automatically select an available one,
this can be helpful for mass VM creation or may be simply just
convenient.
Signed-off-by: Thomas Lamprecht
---
PVE/API2/Qemu.pm | 7 ++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 21fbebb..0665b4c 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -368,7 +368,7 @@ __PACKAGE__->register_method({
properties => PVE::QemuServer::json_config_properties(
{
node => get_standard_option('pve-node'),
- vmid => get_standard_option('pve-vmid', { completion =>
\&PVE::Cluster::complete_next_vmid }),
+ vmid => get_standard_option('pve-vmid-optional', { completion
=> \&PVE::Cluster::complete_next_vmid}),
archive => {
description => "The backup file.",
type => 'string',
@@ -414,6 +414,11 @@ __PACKAGE__->register_method({
my $vmid = extract_param($param, 'vmid');
+ if ($vmid eq '.') {
+ $vmid = PVE::Cluster::next_unused_vmid(100, 10, 1);
+ print "creating VM with VMID '$vmid'\n" if $rpcenv->{type} eq 'cli';
+ }
+
my $archive = extract_param($param, 'archive');
my $storage = extract_param($param, 'storage');
--
2.1.4
___
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel