1
0
mirror of synced 2026-04-26 20:36:26 +00:00

deduplicate xenRunning()

This commit is contained in:
Axel Beckert
2011-11-16 01:10:51 +01:00
parent 1d45cd33ab
commit 2de01d8cbc
4 changed files with 29 additions and 84 deletions

View File

@@ -18,7 +18,7 @@ use strict;
use Exporter 'import';
use vars qw(@EXPORT_OK @EXPORT);
@EXPORT = qw(readConfigurationFile);
@EXPORT = qw(readConfigurationFile xenRunning);
=head1 FUNCTIONS
@@ -103,6 +103,34 @@ sub readConfigurationFile ($$)
close(FILE);
}
=head2 xenRunning
=begin doc
Test to see if the given instance is running.
=end doc
=cut
sub xenRunning ($)
{
my ($hostname) = (@_);
my $running = 0;
open( CMD, "xm list $hostname 2>/dev/null |" ) or
die "Failed to run 'xm list $hostname'";
while (<CMD>)
{
my $line = $_;
$running = 1 if ( $line =~ /\Q$hostname\E/ );
}
close(CMD);
return ($running);
}
=head1 AUTHORS
Steve Kemp, http://www.steve.org.uk/