[pkg-kolab] r1398 - pkg-kolab_testsuite

Mathieu Parent sathieu at alioth.debian.org
Sun Nov 15 14:48:56 UTC 2009


Author: sathieu
Date: 2009-11-15 14:48:56 +0000 (Sun, 15 Nov 2009)
New Revision: 1398

Modified:
   pkg-kolab_testsuite/testsuite
Log:
New functions domain_state and domain_info


Modified: pkg-kolab_testsuite/testsuite
===================================================================
--- pkg-kolab_testsuite/testsuite	2009-11-15 14:30:00 UTC (rev 1397)
+++ pkg-kolab_testsuite/testsuite	2009-11-15 14:48:56 UTC (rev 1398)
@@ -100,12 +100,10 @@
 $| = 1;
 
 my $vmm;
-my @domains;
-my @domain_names;
 my %test_domains;
 
 #=======================================================
-# Functions
+# General functions
 #-------------------------------------------------------
 sub initial_check
 {
@@ -117,14 +115,6 @@
 }
 
 #-------------------------------------------------------
-sub domain_ip
-{
-    my $domid = shift;
-    my $domname = shift;
-    return "192.168.0.".($domid+10);
-}
-
-#-------------------------------------------------------
 sub hosts_file
 {
     my $hosts = "127.0.0.1 localhost\n";
@@ -140,6 +130,41 @@
 }
 
 #=======================================================
+# Domain functions
+#-------------------------------------------------------
+sub domain_ip
+{
+    my $domid = shift;
+    my $domname = shift;
+    return "192.168.0.".($domid+10);
+}
+
+#-------------------------------------------------------
+sub domain_info
+{
+    my $domid = shift;
+    my $domname = shift;
+    
+    my @domains = $vmm->list_domains();
+    while (my $dom = pop @domains) {
+        if($dom->get_name() eq $domname) {
+            return $dom->get_info();
+        }
+    }
+    return {'state' => Sys::Virt::Domain::STATE_SHUTOFF};
+}
+
+#-------------------------------------------------------
+sub domain_state
+{
+    my $domid = shift;
+    my $domname = shift;
+    
+    my $info = domain_info($domid, $domname);
+    return $info->{'state'};
+}
+
+#=======================================================
 # Actions
 #-------------------------------------------------------
 sub domain_bootstrap
@@ -382,11 +407,6 @@
 #-------------------------------------------------------
 initial_check();
 $vmm = Sys::Virt->new(address => $config{'virt_uri'});
- at domains = $vmm->list_domains();
-while (my $dom = pop @domains) {
-    push @domain_names, $dom->get_name();
-}
-
 system("mkdir -p '".$config{'storagepooldir'}."'");
 
 #-------------------------------------------------------
@@ -420,7 +440,7 @@
         my $domip = domain_ip($domid, $domname);
         if ($action eq 'bootstrap') {
             #Cleaning:
-            if($domname ~~ @domain_names) {
+            if(domain_state($domid, $domname) != Sys::Virt::Domain::STATE_SHUTOFF) {
                 print "* Domain already exists.\n";
                 my $dominfo = $vmm->get_domain_by_name($domname)->get_info();
                 if($dominfo->{'state'} == Sys::Virt::Domain::STATE_RUNNING) {




More information about the pkg-kolab-devel mailing list