[test-API][PATCH] Add and update functions in domainAPI

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

 



  * add 9 new block related functions
    block_pull(self, domname, path, bandwidth = 0, flag = 0)
    block_resize(self, domname, path, size, flag = 0)
    block_job_abort(self, domname, path, flag = 0)
    block_job_set_speed(self, domname, path, bandwidth, flag = 0)
    get_block_job_info(self, domname, path, flag = 0)
    get_blkio_parameters(self, domname, flag)
    get_block_io_tune(self, domname, path, flag)
    set_blkio_parameters(self, domname, params, flag)
    set_block_io_tune(self, domname, path, params, flag)

    2 bugs related to parameters for 4 functions(get_blkio_parameters,
    get_block_io_tune, set_blkio_parameters and set_block_io_tune),
    it is considered in this patch, it could be updated later anyway.

  * Add 2 memory parameters function
    get_memory_parameters(self, domname, flag)
    set_memory_parameters(self, domname, params, flag)

    For set_memory_parameters(), the 'params' arguments should be a
    dictionary contains selectable keys: hard_limit, soft_limit,
    swap_hard_limit.
    e.g.
    {'hard_limit':10240, 'soft_limit':100000, 'swap_hard_limit':102400}

  * update 2 functions with problem
    memory_stats(self, domname)
    set_sched_params_flags(self, domname, params, flags)
---
 lib/domainAPI.py |  103 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/lib/domainAPI.py b/lib/domainAPI.py
index a6efab7..1f6ef49 100644
--- a/lib/domainAPI.py
+++ b/lib/domainAPI.py
@@ -546,7 +546,7 @@ class DomainAPI(object):
     def set_sched_params_flags(self, domname, params, flags):
         try:
             dom_obj = self.get_domain_by_name(domname)
-            retval = dom_obj.setSchedulerParameters(params, flags)
+            retval = dom_obj.setSchedulerParametersFlags(params, flags)
             return retval
         except libvirt.libvirtError, e:
             message = e.get_error_message()
@@ -581,6 +581,105 @@ class DomainAPI(object):
             code = e.get_error_code()
             raise exception.LibvirtAPI(message, code)
 
+    def block_pull(self, domname, path, bandwidth = 0, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockPull(path, bandwidth, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def block_resize(self, domname, path, size, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockResize(path, size, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def block_job_abort(self, domname, path, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockJobAbort(path, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def block_job_set_speed(self, domname, path, bandwidth, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockJobSetSpeed(path, bandwidth, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def get_block_job_info(self, domname, path, flag = 0):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockJobInfo(path, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def get_blkio_parameters(self, domname, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blkioParameters(flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def get_block_io_tune(self, domname, path, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.blockIoTune(path, params, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def set_blkio_parameters(self, domname, params, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.setBlkioParameters(params, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def set_block_io_tune(self, domname, path, params, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.setBlockIoTune(path, params, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def get_memory_parameters(self, domname, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.memoryParameters(flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
+    def set_memory_parameters(self, domname, params, flag):
+        try:
+            dom_obj = self.get_domain_by_name(domname)
+            return dom_obj.setMemoryParameters(params, flag)
+        except libvirt.libvirtError, e:
+            message = e.get_error_message()
+            code = e.get_error_code()
+            raise exception.LibvirtAPI(message, code)
+
     def memory_stats(self, domname):
         try:
             dom_obj = self.get_domain_by_name(domname)
@@ -593,7 +692,7 @@ class DomainAPI(object):
     def memory_peek(self, domname, start, size, buffer, flag = 0):
         try:
             dom_obj = self.get_domain_by_name(domname)
-            return dom_obj.blockPeek(start, size, buffer, flag)
+            return dom_obj.memoryPeek(start, size, buffer, flag)
         except libvirt.libvirtError, e:
             message = e.get_error_message()
             code = e.get_error_code()
-- 
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]