1
0
mirror of synced 2026-01-22 02:05:22 +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

@ -350,33 +350,6 @@ sub checkArguments
=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);
}
=begin doc
Delete the named image, and the corresponding configuration file

View File

@ -446,31 +446,3 @@ EOF
$CONFIG{ 'add' } = $1;
}
}
=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);
}

View File

@ -332,34 +332,6 @@ sub updateXenImage
=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 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);
}
=begin doc
Parse the arguments specified upon the command line.

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/