Re: [test-API][PATCH 1/2] Reconnct libvirt after libvirtd restart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/06/2012 03:46 PM, Wayne Sun wrote:
   In domain_nfs_start case, libvirtd will be restarted during test,
   which broke existing connection. User need re-init connection in
   test case, for this:
     * Using sharedmod data dictionary to store Envparser class in
       generator.
     * Do not clear data dictionary in env_inspect, user can update
       it or framework release it at last.
     * Using sharemod_init in env_inspect to re-init conn in
       domain_nfs_start.

For this case, it's better not to use the connection object offered by framework.
      The case could create its own connection through case options.



Signed-off-by: Wayne Sun <gsun@xxxxxxxxxx>
---
  repos/sVirt/domain_nfs_start.py |   11 +++++++++--
  src/env_inspect.py              |    1 -
  src/generator.py                |    2 ++
  3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/repos/sVirt/domain_nfs_start.py b/repos/sVirt/domain_nfs_start.py
index 88d349c..4d48d97 100644
--- a/repos/sVirt/domain_nfs_start.py
+++ b/repos/sVirt/domain_nfs_start.py
@@ -12,7 +12,7 @@ import sys
import libvirt
  from libvirt import libvirtError
-
+from src import env_inspect

The env_inspect is framework module. It is not recommanded to use directly in testcase.


  from src import sharedmod
  from utils import utils
  from shutil import copy
@@ -163,6 +163,8 @@ def domain_nfs_start(params):
          logger.error("Error: fail to get domain %s xml" % guestname)
          return 1
+ conn.close()
+
      # set env
      logger.info("prepare the environment")
      ret = prepare_env(dynamic_ownership, virt_use_nfs, guestname, \
@@ -171,6 +173,11 @@ def domain_nfs_start(params):
          logger.error("failed to prepare the environment")
          return 1
+ # reconnect libvirt
+    env = sharedmod.data['env']
+    env_inspect.sharemod_init(env, logger)
+    conn = sharedmod.libvirtobj['conn']

you could create own connection rather than use the connection object offerred by framework.


+
      domobj = conn.lookupByName(guestname)
logger.info("begin to test start domain from nfs storage")
@@ -283,7 +290,7 @@ def domain_nfs_start(params):
          logger.error("Error: fail to get domain %s state" % guestname)
          return 1
- if state != "shutoff":
+    if state != libvirt.VIR_DOMAIN_SHUTOFF:
          logger.info("shut down the domain %s" % guestname)
          try:
              domobj.destroy()
diff --git a/src/env_inspect.py b/src/env_inspect.py
index b260ff8..a6dc4b1 100644
--- a/src/env_inspect.py
+++ b/src/env_inspect.py
@@ -98,7 +98,6 @@ def sharemod_init(env_parser, logger):
# initialize conn object in sharedmod
      sharedmod.libvirtobj.clear()
-    sharedmod.data.clear()
      sharedmod.libvirtobj['conn'] = conn
      return 0
diff --git a/src/generator.py b/src/generator.py
index 0cdc9de..f01f2fb 100644
--- a/src/generator.py
+++ b/src/generator.py
@@ -30,6 +30,7 @@ from testcasexml import xml_file_to_str
  import env_parser
  import env_inspect
  import format
+import sharedmod
class FuncGen(object):
      """ To generate a callable testcase"""
@@ -56,6 +57,7 @@ class FuncGen(object):
          self.__case_info_save(activity, testrunid)
self.env = env_parser.Envparser("global.cfg")
+        sharedmod.data['env'] = self.env
mapper_obj = mapper.Mapper(activity)
          case_list = mapper_obj.module_casename_func_map()


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]