diff --git a/bin/xen-delete-image b/bin/xen-delete-image index 25087a6..be1dcbc 100755 --- a/bin/xen-delete-image +++ b/bin/xen-delete-image @@ -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 () - { - my $line = $_; - $running = 1 if ( $line =~ /\Q$hostname\E/ ); - } - close(CMD); - - return ($running); -} - - =begin doc Delete the named image, and the corresponding configuration file diff --git a/bin/xen-resize-guest b/bin/xen-resize-guest index 1868a5f..7a7352a 100755 --- a/bin/xen-resize-guest +++ b/bin/xen-resize-guest @@ -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 () - { - my $line = $_; - $running = 1 if ( $line =~ /\Q$hostname\E/ ); - } - close(CMD); - - return ($running); -} diff --git a/bin/xen-update-image b/bin/xen-update-image index 5f57a28..31fa3ae 100755 --- a/bin/xen-update-image +++ b/bin/xen-update-image @@ -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 () - { - my $line = $_; - $running = 1 if ( $line =~ /\Q$hostname\E/ ); - } - close(CMD); - - return ($running); -} - - - =begin doc Parse the arguments specified upon the command line. diff --git a/lib/Xen/Tools/Common.pm b/lib/Xen/Tools/Common.pm index 9ed5155..15a9a44 100644 --- a/lib/Xen/Tools/Common.pm +++ b/lib/Xen/Tools/Common.pm @@ -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 () + { + my $line = $_; + $running = 1 if ( $line =~ /\Q$hostname\E/ ); + } + close(CMD); + + return ($running); +} + =head1 AUTHORS Steve Kemp, http://www.steve.org.uk/