5
0
mirror of git://git.proxmox.com/git/pve-zsync.git synced 2025-03-11 20:58:42 +03:00

vm_exists: directly check if we look for local guest

no need to make a call to ls if we just can check directly..

also remove a (possible problematic)
> my $foo = 'bar' if $boolean;
construct

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2018-11-19 17:56:33 +01:00 committed by Wolfgang Bumiller
parent 9039b8bf87
commit 4fe8bd742e

View File

@ -468,19 +468,18 @@ sub list {
sub vm_exists {
my ($target, $user) = @_;
my @cmd = ('ssh', "$user\@$target->{ip}", '--') if $target->{ip};
my $res = undef;
return undef if !defined($target->{vmid});
eval { $res = run_cmd([@cmd, 'ls', "$QEMU_CONF/$target->{vmid}.conf"]) };
my $conf_fn = "$target->{vmid}.conf";
return "qemu" if $res;
eval { $res = run_cmd([@cmd, 'ls', "$LXC_CONF/$target->{vmid}.conf"]) };
return "lxc" if $res;
if ($target->{ip}) {
my @cmd = ('ssh', "$user\@$target->{ip}", '--', '/bin/ls');
return "qemu" if eval { run_cmd([@cmd, "$QEMU_CONF/$conf_fn"]) };
return "lxc" if eval { run_cmd([@cmd, "$LXC_CONF/$conf_fn"]) };
} else {
return "qemu" if -f "$QEMU_CONF/$conf_fn";
return "lxc" if -f "$LXC_CONF/$conf_fn";
}
return undef;
}