[pkg-kolab] r1422 - pkg-kolab_testsuite

Mathieu Parent sathieu at alioth.debian.org
Thu Nov 26 18:19:56 UTC 2009


Author: sathieu
Date: 2009-11-26 18:19:56 +0000 (Thu, 26 Nov 2009)
New Revision: 1422

Modified:
   pkg-kolab_testsuite/testsuite
Log:
- Refactoring with 'sub remote_command'
- corrected == -> eq
- Corrected path of /etc/udev/rules.d/70-persistent-net.rules



Modified: pkg-kolab_testsuite/testsuite
===================================================================
--- pkg-kolab_testsuite/testsuite	2009-11-26 17:46:56 UTC (rev 1421)
+++ pkg-kolab_testsuite/testsuite	2009-11-26 18:19:56 UTC (rev 1422)
@@ -150,6 +150,23 @@
     return $hosts;
 }
 
+#-------------------------------------------------------
+sub remote_command
+{
+    my $domip = shift;
+    my $command = shift || undef;
+    if(defined($command)) {
+        system('ssh',
+            '-i', $config{'storagepooldir'}.'/key',
+            "root\@$domip",
+            $command);
+    } else {
+        system('ssh',
+            '-i', $config{'storagepooldir'}.'/key',
+            "root\@$domip");
+    }
+}
+
 #=======================================================
 # Domain functions
 #-------------------------------------------------------
@@ -196,7 +213,7 @@
     
     my $domip = domain_ip($domid, $domname);
 
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '$command' ".
+    remote_command($domip, "$command ".
         "| grep -v '^TAP version' | grep -v '^1..' | grep -v '^ok '");
 }
 
@@ -226,7 +243,7 @@
     my $storagepooldir = $config{'storagepooldir'};
     
     print "* Bootstraping:\n";
-    if($config{'vm_install_method'} == 'debootstrap') {
+    if($config{'vm_install_method'} eq 'debootstrap') {
         system("sudo xen-create-image --hostname $domname ".
             "--ip ".domain_ip($domid, $domname)." ".
             "--dist $dist --install-method debootstrap ".
@@ -366,7 +383,7 @@
 
     print "* Flushing MAC adress udev rule:\n";
     domain_pre_chroot($domid, $domname);
-    system("sudo rm $storagepooldir/etc/udev/rules.d/70-persistent-net.rules");
+    system("sudo rm $storagepooldir/domains/$domname/disk/etc/udev/rules.d/70-persistent-net.rules");
     domain_post_chroot($domid, $domname);
     
     print "* Preparing:\n";
@@ -436,17 +453,17 @@
     
     print "* Copying /etc/hosts file:\n";
     my $hosts = hosts_file();
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF > /etc/hosts
+    remote_command($domip, 'cat <<EOF > /etc/hosts
 $hosts
-EOF'");
+EOF');
     # ====
     print "* Preparing packages:\n";
-    if($config{'kolab_installation_method'} == 'native') {
-        system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF > /etc/apt/sources.list.d/kolab.list
+    if($config{'kolab_installation_method'} eq 'native') {
+        remote_command($domip, 'cat <<EOF > /etc/apt/sources.list.d/kolab.list
 #kolab
 deb http://pkg-kolab.alioth.debian.org/packages UNRELEASED/
-EOF'");
-        system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get -qq update'");
+EOF');
+        remote_command($domip, 'apt-get -qq update');
         print "* Following https://wiki.kolab.org/index.php/Debian_-_Administrators_-_Kolab_Installation\n";
     } else {
         die 'Unknow kolab_installation_method: '.$config{'kolab_installation_method'};
@@ -454,21 +471,21 @@
     
     # ====
     print "* Installing:\n";
-    if($config{'kolab_installation_method'} == 'native') {
-        system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install kolabd postfix slapd'");
+    if($config{'kolab_installation_method'} eq 'native') {
+        remote_command($domip, 'DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated install kolabd postfix slapd');
     } else {
         die 'Unknow kolab_installation_method: '.$config{'kolab_installation_method'};
     }
     
     # ====
     print "* Stopping services:\n";
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/apache2 stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolabd stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolab-cyrus stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/postfix stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/saslauthd stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/slapd stop'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/amavis stop #optionally'");
+    remote_command($domip, '/etc/init.d/apache2 stop');
+    remote_command($domip, '/etc/init.d/kolabd stop');
+    remote_command($domip, '/etc/init.d/kolab-cyrus stop');
+    remote_command($domip, '/etc/init.d/postfix stop');
+    remote_command($domip, '/etc/init.d/saslauthd stop');
+    remote_command($domip, '/etc/init.d/slapd stop');
+    remote_command($domip, '/etc/init.d/amavis stop #optionally');
 
     # ====
     print "* Kolab bootstrap:\n";
@@ -782,25 +799,25 @@
     
     if($domid == 0) {
         print "* Enabling LDAPS (master):\n";
-        system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip ".
-            '\'sed -i.bck \\\'s@^SLAPD_SERVICES="ldap:/// ldapi:///"'.
+        remote_command($domip, 
+            'sed -i.bck \\\'s@^SLAPD_SERVICES="ldap:/// ldapi:///"'.
                               '@SLAPD_SERVICES="ldap://127.0.0.1:389/ ldaps:/// ldapi:///"@\\\' '.
-                              '/etc/default/slapd\'');
+                              '/etc/default/slapd');
     }
 
     # ====
     print "* Starting services:\n";
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/amavis start #optionally'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/slapd start'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/saslauthd start'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/postfix start'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolab-cyrus start'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolabd start'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/apache2 start'");
+    remote_command($domip, '/etc/init.d/amavis start #optionally');
+    remote_command($domip, '/etc/init.d/slapd start');
+    remote_command($domip, '/etc/init.d/saslauthd start');
+    remote_command($domip, '/etc/init.d/postfix start');
+    remote_command($domip, '/etc/init.d/kolab-cyrus start');
+    remote_command($domip, '/etc/init.d/kolabd start');
+    remote_command($domip, '/etc/init.d/apache2 start');
 
     # ====
     print "* Installing PHP Unit:\n";
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get -qy install phpunit'");
+    remote_command($domip, 'apt-get -qy install phpunit');
 }
 
 #-------------------------------------------------------
@@ -811,8 +828,8 @@
     my $domip = domain_ip($domid, $domname);
 
     # raising memory limit
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'echo memory_limit = 64M > /etc/php5/conf.d/memory_limit.ini'");
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip \"testsaslauthd -u manager -p '".$config{'kolab_manager_password'}."'\"");
+    remote_command($domip, 'echo memory_limit = 64M > /etc/php5/conf.d/memory_limit.ini');
+    remote_command($domip, "testsaslauthd -u manager -p '".$config{'kolab_manager_password'}."'");
     test_tap($domid, $domname, 'phpunit --tap '.
         '/usr/share/php/tests/Kolab_Filter/Horde/Kolab/Filter/AllTests.php');
     test_tap($domid, $domname, 'phpunit --tap '.
@@ -826,7 +843,7 @@
     my $domname = shift;
     my $domip = domain_ip($domid, $domname);
     
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip");
+    remote_command($domip);
 }
 
 #=======================================================




More information about the pkg-kolab-devel mailing list