qm rescan: add dryrun option

tells an user what would get touched, so he has a chance to fix
unwanted things before changes are actually made.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2018-07-11 08:40:07 +02:00 committed by Dietmar Maurer
parent 53b81297c4
commit 9224dceefe
2 changed files with 13 additions and 3 deletions

View File

@ -404,13 +404,23 @@ __PACKAGE__->register_method ({
optional => 1,
completion => \&PVE::QemuServer::complete_vmid,
}),
dryrun => {
type => 'boolean',
optional => 1,
default => 0,
description => 'Do not actually write changes out to conifg.',
},
},
},
returns => { type => 'null'},
code => sub {
my ($param) = @_;
PVE::QemuServer::rescan($param->{vmid});
my $dryrun = $param->{dryrun};
print "NOTE: running in dry-run mode, won't write changes out!\n" if $dryrun;
PVE::QemuServer::rescan($param->{vmid}, 0, $dryrun);
return undef;
}});

View File

@ -5606,7 +5606,7 @@ sub update_disksize {
}
sub rescan {
my ($vmid, $nolock) = @_;
my ($vmid, $nolock, $dryrun) = @_;
my $cfg = PVE::Storage::config();
@ -5634,7 +5634,7 @@ sub rescan {
my $changes = update_disksize($vmid, $conf, $vm_volids);
PVE::QemuConfig->write_config($vmid, $conf) if $changes;
PVE::QemuConfig->write_config($vmid, $conf) if $changes && !$dryrun;
};
if (defined($vmid)) {