[pkg-kolab] r1428 - pkg-kolab_testsuite
Mathieu Parent
sathieu at alioth.debian.org
Thu Nov 26 22:19:44 UTC 2009
Author: sathieu
Date: 2009-11-26 22:19:44 +0000 (Thu, 26 Nov 2009)
New Revision: 1428
Modified:
pkg-kolab_testsuite/testsuite
Log:
Print return value for local commands
Modified: pkg-kolab_testsuite/testsuite
===================================================================
--- pkg-kolab_testsuite/testsuite 2009-11-26 22:16:37 UTC (rev 1427)
+++ pkg-kolab_testsuite/testsuite 2009-11-26 22:19:44 UTC (rev 1428)
@@ -142,6 +142,13 @@
}
#-------------------------------------------------------
+sub local_command
+{
+ my $command = shift;
+ my $ret = system($command);
+ print "Return value: $ret\n" if($ret);
+}
+#-------------------------------------------------------
sub remote_command
{
my $domip = shift;
@@ -157,9 +164,7 @@
'-i', conf('storage_pool_dir').'/key',
"root\@$domip");
}
- if($ret) {
- print "Return value: $ret\n";
- }
+ print "Return value: $ret\n" if($ret);
}
#=======================================================
@@ -239,7 +244,7 @@
print "* Bootstraping:\n";
if(conf('vm_install_method') eq 'debootstrap') {
- system("sudo xen-create-image --hostname $domname ".
+ local_command("sudo xen-create-image --hostname $domname ".
"--ip ".domain_ip($domid, $domname)." ".
"--dist $dist --install-method debootstrap ".
"--dir '$storagepooldir' ".
@@ -250,7 +255,7 @@
} else {
die 'Unknow vm_install_method: '.conf('vm_install_method');
}
- system("sudo chown -R ".conf('user').":".conf('group')." '$storagepooldir'");
+ local_command("sudo chown -R ".conf('user').":".conf('group')." '$storagepooldir'");
}
#-------------------------------------------------------
@@ -262,8 +267,8 @@
my $storagepooldir = conf('storage_pool_dir');
print "* Preparing chroot";
- system("sudo mkdir -p '$storagepooldir/domains/$domname/disk'");
- system("sudo mount -o loop '$storagepooldir/domains/$domname/disk.img' '$storagepooldir/domains/$domname/disk'");
+ local_command("sudo mkdir -p '$storagepooldir/domains/$domname/disk'");
+ local_command("sudo mount -o loop '$storagepooldir/domains/$domname/disk.img' '$storagepooldir/domains/$domname/disk'");
print ".\n";
}
@@ -276,8 +281,8 @@
my $storagepooldir = conf('storage_pool_dir');
print "* Releasing chroot";
- system("sudo umount '$storagepooldir/domains/$domname/disk'");
- system("sudo rmdir '$storagepooldir/domains/$domname/disk'");
+ local_command("sudo umount '$storagepooldir/domains/$domname/disk'");
+ local_command("sudo rmdir '$storagepooldir/domains/$domname/disk'");
print ".\n";
}
@@ -292,8 +297,8 @@
my $DEVICE = '/dev/loop0';
#extlinux
- system("sudo extlinux --install $CHROOT");
- system("cat <<EOF > /tmp/pkg-kolab-extlinux.conf
+ local_command("sudo extlinux --install $CHROOT");
+ local_command("cat <<EOF > /tmp/pkg-kolab-extlinux.conf
default linux
prompt 1
timeout 50
@@ -302,10 +307,10 @@
append root=/dev/hda initrd=./initrd.img
EOF
");
- system("sudo mv /tmp/pkg-kolab-extlinux.conf '$CHROOT/extlinux.conf'");
+ local_command("sudo mv /tmp/pkg-kolab-extlinux.conf '$CHROOT/extlinux.conf'");
#linux kernel
- system("cat <<EOF > $storagepooldir/kernel-img.conf
+ local_command("cat <<EOF > $storagepooldir/kernel-img.conf
do_symlinks = yes
relative_links = yes
do_bootloader = no
@@ -316,12 +321,12 @@
postrm_hook = #update-grub
EOF
");
- system("sudo mv $storagepooldir/kernel-img.conf '$CHROOT/etc/kernel-img.conf'");
- system("sudo chroot $CHROOT apt-get install -q linux-image-2.6.30-2-686");
+ local_command("sudo mv $storagepooldir/kernel-img.conf '$CHROOT/etc/kernel-img.conf'");
+ local_command("sudo chroot $CHROOT apt-get install -q linux-image-2.6.30-2-686");
#remove xen specific
- system("sudo chroot $CHROOT aptitude -y purge libc6-xen");
- system("sudo sed -i s/hvc0/tty1/ $CHROOT/etc/inittab");
+ local_command("sudo chroot $CHROOT aptitude -y purge libc6-xen");
+ local_command("sudo sed -i s/hvc0/tty1/ $CHROOT/etc/inittab");
}
#-------------------------------------------------------
@@ -339,10 +344,10 @@
}
print "* Adding to authorized_keys and copying ssh private key";
- system("sudo mkdir -p '$storagepooldir/domains/$domname/disk/root/.ssh'");
- system("sudo cp '$storagepooldir/key.pub' '$storagepooldir/domains/$domname/disk/root/.ssh/authorized_keys'");
+ local_command("sudo mkdir -p '$storagepooldir/domains/$domname/disk/root/.ssh'");
+ local_command("sudo cp '$storagepooldir/key.pub' '$storagepooldir/domains/$domname/disk/root/.ssh/authorized_keys'");
# to avoid password prompt from one domain to another
- system("sudo cp '$storagepooldir/key' '$storagepooldir/domains/$domname/disk/root/.ssh/id_rsa'");
+ local_command("sudo cp '$storagepooldir/key' '$storagepooldir/domains/$domname/disk/root/.ssh/id_rsa'");
print ".\n";
domain_post_chroot($domid, $domname);
@@ -359,7 +364,7 @@
domain_pre_chroot($domid, $domname);
print "* Chrooting:\n";
- system("sudo chroot '$storagepooldir/domains/$domname/disk/'");
+ local_command("sudo chroot '$storagepooldir/domains/$domname/disk/'");
domain_post_chroot($domid, $domname);
}
@@ -378,24 +383,24 @@
print "* Flushing MAC adress udev rule:\n";
domain_pre_chroot($domid, $domname);
- system("sudo rm $storagepooldir/domains/$domname/disk/etc/udev/rules.d/70-persistent-net.rules");
+ local_command("sudo rm $storagepooldir/domains/$domname/disk/etc/udev/rules.d/70-persistent-net.rules");
domain_post_chroot($domid, $domname);
print "* Preparing:\n";
if(conf('virt_type') eq 'vbox') {
#release
- system("VBoxManage unregistervm '$domname' --delete");
- system("VBoxManage closemedium disk '$storagepooldir/domains/$domname/disk.vmdk'");
- system("sudo rm '$storagepooldir/domains/$domname/disk.vmdk'");
+ local_command("VBoxManage unregistervm '$domname' --delete");
+ local_command("VBoxManage closemedium disk '$storagepooldir/domains/$domname/disk.vmdk'");
+ local_command("sudo rm '$storagepooldir/domains/$domname/disk.vmdk'");
#volume
my $loopdev = `sudo losetup --find --show '$storagepooldir/domains/$domname/disk.img'`;
$loopdev =~ s/\s+$//;
- system("sudo chgrp disk '$storagepooldir/domains/$domname'");
- system("sudo chmod g+w '$storagepooldir/domains/$domname'");
- system("VBoxManage internalcommands createrawvmdk ".
+ local_command("sudo chgrp disk '$storagepooldir/domains/$domname'");
+ local_command("sudo chmod g+w '$storagepooldir/domains/$domname'");
+ local_command("VBoxManage internalcommands createrawvmdk ".
"-filename '$storagepooldir/domains/$domname/disk.vmdk' ".
"-rawdisk '$loopdev' ");
- system("VBoxManage openmedium disk '$storagepooldir/domains/$domname/disk.vmdk'");
+ local_command("VBoxManage openmedium disk '$storagepooldir/domains/$domname/disk.vmdk'");
#vm
print "* Defining:\n";
UUID::generate(my $uuid);
@@ -870,7 +875,7 @@
#-------------------------------------------------------
initial_check();
$vmm = Sys::Virt->new(address => conf('virt_uri'));
-system("mkdir -p '".conf('storage_pool_dir')."'");
+local_command("mkdir -p '".conf('storage_pool_dir')."'");
#-------------------------------------------------------
my $o_help = 0;
@@ -908,7 +913,7 @@
#SSH
if ($action eq 'preboot_install') {
#generate common ssh key
- system("ssh-keygen -f '".conf('storage_pool_dir')."/key' -N ''");
+ local_command("ssh-keygen -f '".conf('storage_pool_dir')."/key' -N ''");
}
#Main loop
More information about the pkg-kolab-devel
mailing list