2007-06-12 14:40:58 by steve
xen-update-image:
1. Only work with xen guest which aren't running.
2. Work correctly for LVM storage.
This commit is contained in:
parent
ef4cfdbcb3
commit
9d295570f3
@ -87,7 +87,7 @@ Show the version number and exit.
|
||||
--
|
||||
http://www.steve.org.uk/
|
||||
|
||||
$Id: xen-update-image,v 1.25 2007-05-24 17:35:18 steve Exp $
|
||||
$Id: xen-update-image,v 1.26 2007-06-12 14:40:58 steve Exp $
|
||||
|
||||
=cut
|
||||
|
||||
@ -170,7 +170,14 @@ E_O_ROOT
|
||||
#
|
||||
while( my $name = shift )
|
||||
{
|
||||
updateXenImage( $name );
|
||||
if ( !xenRunning( $name ) )
|
||||
{
|
||||
updateXenImage( $name );
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Skipping xen guest '$name' - it appears to be running.\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -197,9 +204,9 @@ sub updateXenImage
|
||||
# Create a temporary directory, and prepare to mount the
|
||||
# image there.
|
||||
#
|
||||
my $tmp = tempdir( CLEANUP => 1 );
|
||||
my $img = '';
|
||||
|
||||
my $tmp = tempdir( CLEANUP => 1 );
|
||||
my $img = '';
|
||||
my $mount_cmd = '';
|
||||
|
||||
#
|
||||
# If we're dealing with loopback images find the main one,
|
||||
@ -215,6 +222,8 @@ sub updateXenImage
|
||||
print "Disk image '$img' for host '$name' not found\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$mount_cmd = "mount -t auto -o loop $img $tmp";
|
||||
}
|
||||
elsif ( $CONFIG{'lvm'} )
|
||||
{
|
||||
@ -227,6 +236,8 @@ sub updateXenImage
|
||||
print "Logical volume '$img' for host '$name' not found\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$mount_cmd = "mount -t auto $img $tmp";
|
||||
}
|
||||
elsif ( $CONFIG{'evms'} )
|
||||
{
|
||||
@ -251,6 +262,8 @@ sub updateXenImage
|
||||
print "EVMS volume '$img' for host '$name' not found\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$mount_cmd = "mount -t auto $img $tmp";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -260,14 +273,13 @@ sub updateXenImage
|
||||
#
|
||||
# Mount the image.
|
||||
#
|
||||
my $mount_cmd = "mount -t auto -o loop $img $tmp";
|
||||
`$mount_cmd`;
|
||||
|
||||
#
|
||||
# Make sure this is a Debian image.
|
||||
#
|
||||
if ( ( -e $tmp . "/usr/bin/apt-get" ) &&
|
||||
( -e $tmp . "/etc/apt/sources.list" ) )
|
||||
( -x $tmp . "/usr/bin/apt-get" ) )
|
||||
{
|
||||
#
|
||||
# Now run the update command.
|
||||
@ -289,11 +301,44 @@ sub updateXenImage
|
||||
#
|
||||
# Unmount
|
||||
#
|
||||
`umount $tmp`;
|
||||
`umount -l $tmp`;
|
||||
`umount $tmp 2>/dev/null >/dev/null`;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=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
|
||||
|
||||
Read the configuration file specified.
|
||||
@ -400,7 +445,7 @@ sub parseCommandLineArguments
|
||||
|
||||
if ( $VERSION )
|
||||
{
|
||||
my $REVISION = '$Revision: 1.25 $';
|
||||
my $REVISION = '$Revision: 1.26 $';
|
||||
|
||||
if ( $REVISION =~ /1.([0-9.]+) / )
|
||||
{
|
||||
|
||||
1
debian/changelog
vendored
1
debian/changelog
vendored
@ -7,6 +7,7 @@ xen-tools (3.4-2) unstable; urgency=low
|
||||
* Added support for Ubuntu Feisty + Gutsy
|
||||
* Use "policy-rc.d" to prevent daemons from starting inside our
|
||||
chroot().
|
||||
* xen-update-image will now skip Xen guests which are running.
|
||||
|
||||
-- Radu Spineanu <radu@debian.org> Tue, 29 May 2007 01:09:40 +0300
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user