[test-API][PATCH] Add 8 new APIs in domainAPI

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

 



  * new APIs
    reset(self, domname, flag = 0)
    get_vcpu_pin_info(self, domname, flag)
    is_updated(self, domname)
    inject_NMI(self, domname, flag = 0)
    open_console(self, domname, dev_name, stream, flag = 0)
    open_graphics(self, domname, idx, fd, flag = 1)
    screenshot(self, domname, stream, screen, flag = 0)
    get_migrate_max_speed(self, domname, flag = 0)

    A bug is filed to migrateGetMaxSpeed() about parameters, it'll
    affect get_migrate_max_speed() function, but the parameters should
    remain the status quo. Change will be followed up anyway.

    open_graphics() will not work now for lack qemu support, missing
    add_client qemu command.

    for dev_name in open_console, pass the alias name of console, serial
    or parallel port.

  * deleted outdated function get_ref(self, domname)
---
 lib/domainAPI.py |   91 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 83 insertions(+), 8 deletions(-)

diff --git a/lib/domainAPI.py b/lib/domainAPI.py
index 91f2ba3..a8086ab 100644
--- a/lib/domainAPI.py
+++ b/lib/domainAPI.py
@@ -261,6 +261,16 @@ class DomainAPI(object):
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
+    def reset(self, domname, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            retval = dom_obj.reset(flag)
+            return retval
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
     def get_info(self, domname):
         try:
             dom_obj = self.get_domain_by_name(domname)
@@ -335,36 +345,46 @@ class DomainAPI(object):
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
-    def get_ref(self, domname):
+    def get_vcpus(self, domname):
         try:
             dom_obj = self.get_domain_by_name(domname)
-            ref = dom_obj.ref()
-            return ref
+            vcpu_info = dom_obj.vcpus()
+            return vcpu_info
         except libvirt.libvirtError, e:
             message = e.get_error_message()
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
-    def get_vcpus(self, domname):
+    def set_pin_vcpu(self, domname, vcpu, cpumap):
         try:
             dom_obj = self.get_domain_by_name(domname)
-            vcpu_info = dom_obj.vcpus()
-            return vcpu_info
+            pin_vcpu = dom_obj.pinVcpu(vcpu, cpumap)
+            return pin_vcpu
         except libvirt.libvirtError, e:
             message = e.get_error_message()
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
-    def set_pin_vcpu(self, domname, vcpu, cpumap):
+    def set_pin_vcpu_flags(self, domname, vcpu, cpumap, flag):
         try:
             dom_obj = self.get_domain_by_name(domname)
-            pin_vcpu = dom_obj.pinVcpu(vcpu, cpumap)
+            pin_vcpu = dom_obj.pinVcpuFlags(vcpu, cpumap, flag)
             return pin_vcpu
         except libvirt.libvirtError, e:
             message = e.get_error_message()
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
+    def get_vcpu_pin_info(self, domname, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            pin_vcpu_info = dom_obj.vcpuPinInfo(flag)
+            return pin_vcpu_info
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
     def get_uuid(self, domname):
         try:
             dom_obj = self.get_domain_by_name(domname)
@@ -716,6 +736,15 @@ class DomainAPI(object):
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
+    def is_updated(self, domname):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.isUpdated()
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
     def job_info(self, domname):
         try:
             dom_obj = self.get_domain_by_name(domname)
@@ -878,6 +907,50 @@ class DomainAPI(object):
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
+    def inject_NMI(self, domname, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.injectNMI(flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def open_console(self, domname, dev_name, stream, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.openConsole(dev_name, stream, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def open_graphics(self, domname, idx, fd, flag = 1):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.openGraphics(idx, fd, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def screenshot(self, domname, stream, screen, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.screenshot(stream, screen, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def get_migrate_max_speed(self, domname, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.migrateGetMaxSpeed(flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
 
 # DomainState
 VIR_DOMAIN_NOSTATE = 0
@@ -903,3 +976,5 @@ VIR_DOMAIN_AFFECT_CURRENT = 0
 VIR_DOMAIN_AFFECT_LIVE = 1
 VIR_DOMAIN_AFFECT_CONFIG = 2
 
+# virDomainOpenGraphicsFlags
+VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH = 1
-- 
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]