Correct Sys::Virt version check

Fix broken LVM behavior when faced with a pre-built LVM VG/PV (as reported by Michael Fenn)

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15535 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2013-03-15 19:42:25 +00:00
parent 1dc28f2540
commit 4337554e71

View File

@ -40,7 +40,7 @@ my $confdata; #a reference to serve as a common pointer betweer VMCommon functio
my $libvirtsupport;
$libvirtsupport = eval {
require Sys::Virt;
if (Sys::Virt->VERSION < "0.2.0") {
if (Sys::Virt->VERSION =~ /^0\.[10]\./) {
die;
}
1;
@ -176,6 +176,7 @@ sub get_storage_pool_by_url {
push @currpools,$virtconn->list_defined_storage_pools();
my $poolobj;
my $pool;
my $islvm=0;
foreach my $poolo (@currpools) {
$poolobj = $poolo;
$pool = $parser->parse_string($poolobj->get_xml_description()); #XMLin($poolobj->get_xml_description());
@ -206,6 +207,7 @@ sub get_storage_pool_by_url {
my $vgname = $1;
my $checkname = $pool->findnodes("/pool/name/text()")->[0]->data;
if ($checkname eq $vgname) {
$islvm=1;
last;
}
} elsif ($pool->findnodes('/pool/name/text()')->[0]->data eq $url) { #$pool->{name} eq $url) {
@ -216,7 +218,7 @@ sub get_storage_pool_by_url {
if ($pool) {
my $inf=$poolobj->get_info();
if ($inf->{state} == 0) { #Sys::Virt::StoragePool::STATE_INACTIVE) { #if pool is currently inactive, bring it up
$poolobj->build();
unless ($islvm) { $poolobj->build(); } #if lvm and defined, it's almost certainly been built
$poolobj->create();
}
eval { #we *try* to do this, but various things may interfere.
@ -226,7 +228,13 @@ sub get_storage_pool_by_url {
return $poolobj;
}
$poolobj = $virtconn->define_storage_pool(build_pool_xml($url,$mounthost));
$poolobj->build();
eval { $poolobj->build(); };
if ($@) {
my $error = $@;
unless ($error =~ /vgcreate.*exit status 3/ or $error =~ /pvcreate.*exit status 5/) {
die $@;
}
}
$poolobj->create();
eval { #wrap in eval, not likely to fail here, but calling it at all may be superfluous anyway
$poolobj->refresh();