optimize libvirt ssh connections a bit

git-svn-id: http://www.observium.org/svn/observer/trunk@2141 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-04-22 20:45:39 +00:00
parent 2f70d075cd
commit 95ab5ad3ac

View File

@ -10,6 +10,8 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == "linux" )
echo("Libvirt VM: ");
$ssh_ok = 0;
foreach ($config['libvirt_protocols'] as $method)
{
if (strstr($method,'qemu'))
@ -21,21 +23,15 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == "linux" )
$uri = $method.'://' . $device['hostname'];
}
$ok = 0;
if (strstr($method,'ssh'))
if (strstr($method,'ssh') && !$ssh_ok)
{
# Check if we are using SSH if we can log in without password - without blocking the discovery
# Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-)
exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" ' . $device['hostname'] . ' echo', $out, $ret);
if ($ret != 255) { $ok = 1; }
}
else
{
$ok = 1;
if ($ret != 255) { $ssh_ok = 1; }
}
if ($ok)
if ($ssh_ok || !strstr($method,'ssh'))
{
# Fetch virtual machine list
unset($domlist);