[test-API PATCH] streamAPI: Create stream objects that are already encapsulated

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

 



With this patch, the newStream() method of the ConnectAPI class returns
an already encapsulated StreamAPI object .
 *lib/connectAPI.py: - modify newStream method to return StreamAPI
                       object
 *lib/streamAPI.py: - modify constructor to take virStream objects
---
 lib/connectAPI.py |    4 +++-
 lib/streamAPI.py  |    9 ++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/lib/connectAPI.py b/lib/connectAPI.py
index f52467f..2723fc8 100644
--- a/lib/connectAPI.py
+++ b/lib/connectAPI.py
@@ -24,6 +24,7 @@ import os
 import re

 import libvirt
+from lib import streamAPI

 def append_path(path):
     """Append root path of package"""
@@ -226,7 +227,8 @@ class ConnectAPI(object):

     def newStream(self, flag = 0):
         try:
-            return self.conn.newStream(flag)
+            st_obj = self.conn.newStream(flag)
+            return streamAPI.StreamAPI(st_obj)
         except libvirt.libvirtError, e:
             message = e.get_error_message()
             code = e.get_error_code()
diff --git a/lib/streamAPI.py b/lib/streamAPI.py
index 18ce71e..f551992 100644
--- a/lib/streamAPI.py
+++ b/lib/streamAPI.py
@@ -38,13 +38,8 @@ append_path(result.group(0))
 import exception

 class StreamAPI(object):
-    def __init__(self, conn, flags = 0):
-        try:
-            self.stream = conn.newStream(flags)
-        except libvirt.libvirtError, e:
-            message = e.get_error_message()
-            code = e.get_error_code()
-            raise exception.LibvirtAPI(message, code)
+    def __init__(self, stream):
+        self.stream = stream;

     def getStream(self):
         return self.stream
-- 
1.7.3.4

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