[Libvirt-test-API][PATCH 3/6] add flags option to start to have domain started with flags support

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

 



---
 repos/domain/start.py |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/repos/domain/start.py b/repos/domain/start.py
index 34906e5..39ac47f 100644
--- a/repos/domain/start.py
+++ b/repos/domain/start.py
@@ -31,6 +31,9 @@ from lib import domainAPI
 from utils.Python import utils
 from exception import LibvirtAPI
 
+NONE = 0
+START_PAUSED = 1
+
 def return_close(conn, logger, ret):
     conn.close()
     logger.info("closed hypervisor connection")
@@ -62,7 +65,8 @@ def start(params):
         {'logger': logger, 'guestname': guestname}
 
         logger -- an object of utils/Python/log.py
-        guestname -- same as the domain name
+        mandatory arguments : guestname -- same as the domain name
+	optional arguments : flags -- domain create flags <none|start_paused>
 
         Return 0 on SUCCESS or 1 on FAILURE
     """
@@ -72,6 +76,13 @@ def start(params):
     domname = params['guestname']
     logger = params['logger']
 
+    flags = None
+    if params.has_key('flags'):
+        flags = params['flags']
+        if flags != 'none' and flags != 'start_paused':
+            logger.error("flags value either \"none\" or \"start_paused\"");
+            return 1
+
     # Connect to local hypervisor connection URI
     util = utils.Utils()
     uri = util.get_uri('127.0.0.1')
@@ -84,12 +95,29 @@ def start(params):
     logger.info('start domain')
 
     try:
-        dom_obj.start(domname)
+        if flags == "none":
+            dom_obj.start_with_flags(domname, NONE)
+        elif flags == "start_paused":
+            dom_obj.start_with_flags(domname, START_PAUSED)
+        elif not flags:
+            dom_obj.start(domname)
+        else:
+            logger.error("flags error")
+            return (conn, logger, 1)
     except LibvirtAPI, e:
         logger.error(str(e))
         logger.error("start failed")
         return return_close(conn, logger, 1)
 
+    if flags == "start_paused":
+        state = dom_obj.get_state(domname)
+        if state == "paused":
+            logger.info("guest start with state paused successfully")
+            return return_close(conn, logger, 0)
+        else:
+            logger.error("guest state error")
+            return return_close(conn, logger, 1)
+
     while timeout:
         time.sleep(10)
         timeout -= 10
-- 
1.7.1

--
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]