refactor diskmanagement lock_file calls

so that we only have one place where we reference the lockfile
and the timeout

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2018-08-08 10:20:08 +02:00
committed by Dietmar Maurer
parent 7058abe29e
commit e39e8ee213
5 changed files with 11 additions and 13 deletions

View File

@ -214,7 +214,7 @@ __PACKAGE__->register_method ({
my $mountunitname = "mnt-pve-$name.mount";
my $mountunitpath = "/etc/systemd/system/$mountunitname";
lock_file('/run/lock/pve-diskmanage.lck', undef, sub {
PVE::Diskmanage::locked_disk_action(sub {
# create partition
my $cmd = [$SGDISK, '-n1', '-t1:8300', $dev];
print "# ", join(' ', @$cmd), "\n";
@ -279,11 +279,8 @@ __PACKAGE__->register_method ({
PVE::API2::Storage::Config->create($storage_params);
}
});
die $@ if $@;
};
return $rpcenv->fork_worker('dircreate', $name, $user, $worker);
}});