Hi
I'm replying to this thread :
http://mail-archives.apache.org/mod_mbox/vcl-user/201209.mbox/%[email protected]%3e
I know this is old post, but I got the same error with libvirt.pm from 2.3.2
version.
I've updated the code in libvirt.pm::get_domain_info() to remove white spaces:
$name =~ s/^\s+//;
$name =~ s/\s+$//;
get_domain_info.txt attached for reference.
--
Thank you,
Dmitri Chebotarov
VCL Sys Eng, Engineering & Architectural Support, TSD - Ent Servers & Messaging
223 Aquia Building, Ffx, MSN: 1B5
Phone: (703) 993-6175 | Fax: (703) 993-3404
sub get_domain_info {
my $self = shift;
unless (ref($self) && $self->isa('VCL::Module')) {
notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
return;
}
my $node_name = $self->data->get_vmhost_short_name();
my $command = "virsh list --all";
my ($exit_status, $output) = $self->vmhost_os->execute($command);
if (!defined($output)) {
notify($ERRORS{'WARNING'}, 0, "failed to execute virsh command
to list defined domains on $node_name");
return;
}
elsif ($exit_status ne '0') {
notify($ERRORS{'WARNING'}, 0, "failed to list defined domains
on $node_name\ncommand: $command\nexit status: $exit_status\noutput:\n" .
join("\n", @$output));
return;
}
else {
notify($ERRORS{'DEBUG'}, 0, "listed defined domains on
$node_name\ncommand: $command\noutput:\n" . join("\n", @$output));
}
# [root@vclh3-10 images]# virsh list --all
# Id Name State
# ----------------------------------
# 14 test-name running
# - test-2gb shut off
# - vclv99-197: vmwarelinux-RHEL54Small2251-v1 shut off
my $defined_domains = {};
my $domain_info_string = '';
for my $line (@$output) {
my ($id, $name, $state) = $line =~
/^\s*([\d\-]+)\s(.+?)\s+(\w+|shut off)$/g;
next if (!defined($id));
$name =~ s/^\s+//;
$name =~ s/\s+$//;
$defined_domains->{$name}{state} = $state;
$defined_domains->{$name}{id} = $id if ($id =~ /\d/);
$domain_info_string .= "$id. $name ($state)\n";
}
if ($defined_domains) {
notify($ERRORS{'DEBUG'}, 0, "retrieved domain info from
$node_name:\n$domain_info_string");
}
else {
notify($ERRORS{'DEBUG'}, 0, "no domains are defined on
$node_name");
}
return $defined_domains;
}