api: status: import run_command
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
@ -13,7 +13,7 @@ use PVE::JSONSchema qw(get_standard_option);
|
|||||||
use PVE::RESTHandler;
|
use PVE::RESTHandler;
|
||||||
use PVE::RPCEnvironment;
|
use PVE::RPCEnvironment;
|
||||||
use PVE::RRD;
|
use PVE::RRD;
|
||||||
use PVE::Tools;
|
use PVE::Tools qw(run_command);
|
||||||
|
|
||||||
use PVE::API2::Storage::Content;
|
use PVE::API2::Storage::Content;
|
||||||
use PVE::API2::Storage::FileRestore;
|
use PVE::API2::Storage::FileRestore;
|
||||||
@ -456,15 +456,15 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my @remcmd = ('/usr/bin/ssh', @ssh_options, $remip, '--');
|
my @remcmd = ('/usr/bin/ssh', @ssh_options, $remip, '--');
|
||||||
|
|
||||||
eval {
|
eval { # activate remote storage
|
||||||
# activate remote storage
|
run_command([@remcmd, '/usr/sbin/pvesm', 'status', '--storage', $param->{storage}]);
|
||||||
PVE::Tools::run_command([@remcmd, '/usr/sbin/pvesm', 'status',
|
|
||||||
'--storage', $param->{storage}]);
|
|
||||||
};
|
};
|
||||||
die "can't activate storage '$param->{storage}' on node '$node': $@\n" if $@;
|
die "can't activate storage '$param->{storage}' on node '$node': $@\n" if $@;
|
||||||
|
|
||||||
PVE::Tools::run_command([@remcmd, '/bin/mkdir', '-p', '--', PVE::Tools::shell_quote($dirname)],
|
run_command(
|
||||||
errmsg => "mkdir failed");
|
[@remcmd, '/bin/mkdir', '-p', '--', PVE::Tools::shell_quote($dirname)],
|
||||||
|
errmsg => "mkdir failed",
|
||||||
|
);
|
||||||
|
|
||||||
$cmd = ['/usr/bin/scp', @ssh_options, '-p', '--', $tmpfilename, "[$remip]:" . PVE::Tools::shell_quote($dest)];
|
$cmd = ['/usr/bin/scp', @ssh_options, '-p', '--', $tmpfilename, "[$remip]:" . PVE::Tools::shell_quote($dest)];
|
||||||
$err_cmd = [@remcmd, 'unlink', '--', $dest];
|
$err_cmd = [@remcmd, 'unlink', '--', $dest];
|
||||||
@ -484,9 +484,9 @@ __PACKAGE__->register_method ({
|
|||||||
print "file size is: $size\n";
|
print "file size is: $size\n";
|
||||||
print "command: " . join(' ', @$cmd) . "\n";
|
print "command: " . join(' ', @$cmd) . "\n";
|
||||||
|
|
||||||
eval { PVE::Tools::run_command($cmd, errmsg => 'import failed'); };
|
eval { run_command($cmd, errmsg => 'import failed'); };
|
||||||
if (my $err = $@) {
|
if (my $err = $@) {
|
||||||
eval { PVE::Tools::run_command($err_cmd); };
|
eval { run_command($err_cmd) };
|
||||||
die $err;
|
die $err;
|
||||||
}
|
}
|
||||||
print "finished file import successfully\n";
|
print "finished file import successfully\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user