* add 8 new APIs get_sys_info(self, flag = 0) get_memory_stats(self, cellNum, flag = 0) get_cpu_stats(self, cpuNum, flag = 0) is_alive(self) change_begin(self, flag = 0) change_commit(self, flag = 0) change_rollback(self, flag = 0) suspend_for_duration(self, target, duration, flag = 0) * remove outdated ref(self, uri) function * fix typo in following functions migrate(self, domain, flags, dname, uri, bandwidth) networkLookupByUUID(self, uuid) numOfDefinedDomains(self) numOfDomains(self) nwfilterLookupByUUID(self, uuid) --- lib/connectAPI.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 72 insertions(+), 11 deletions(-) diff --git a/lib/connectAPI.py b/lib/connectAPI.py index 9f2b728..87b0a59 100644 --- a/lib/connectAPI.py +++ b/lib/connectAPI.py @@ -105,6 +105,15 @@ class ConnectAPI(object): code = e.get_error_code() raise exception.LibvirtAPI(message, code) + def get_sys_info(self, flag = 0): + try: + sysinfo = self.conn.getSysinfo(flag) + return sysinfo + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + def get_type(self): try: type = self.conn.getType() @@ -123,19 +132,18 @@ class ConnectAPI(object): code = e.get_error_code() raise exception.LibvirtAPI(message, code) - def ref(self, uri): + def get_cells_free_memory(self, startCell, maxCells): try: - refer = self.conn.ref() - return refer + cfreemem = self.conn.getCellsFreeMemory(startCell, maxCells) + return cfreemem except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() raise exception.LibvirtAPI(message, code) - def get_cells_free_memory(self, startCell, maxCells): + def get_memory_stats(self, cellNum, flag = 0): try: - cfreemem = self.conn.getCellsFreeMemory(startCell, maxCells) - return cfreemem + return self.conn.getMemoryStats(cellNum, flag) except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -158,6 +166,14 @@ class ConnectAPI(object): code = e.get_error_code() raise exception.LibvirtAPI(message, code) + def get_cpu_stats(self, cpuNum, flag = 0): + try: + return self.conn.getCPUStats(cpuNum, flag) + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + def compare_cpu(self, xmlDesc, flag = 0): try: return self.conn.compareCPU(xmlDesc, flag) @@ -208,6 +224,14 @@ class ConnectAPI(object): code = e.get_error_code() raise exception.LibvirtAPI(message, code) + def is_alive(self): + try: + return self.conn.isAlive() + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + def isEncrypted(self): try: return self.conn.isEncrypted() @@ -307,7 +331,7 @@ class ConnectAPI(object): def migrate(self, domain, flags, dname, uri, bandwidth): try: - return self.migrate(self, domain, flags, dname, uri, bandwidth) + return self.conn.migrate(domain, flags, dname, uri, bandwidth) except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -315,7 +339,7 @@ class ConnectAPI(object): def networkLookupByUUID(self, uuid): try: - return self.networkLookupByUUID(self, uuid) + return self.conn.networkLookupByUUID(uuid) except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -323,7 +347,7 @@ class ConnectAPI(object): def numOfDefinedDomains(self): try: - return self.numOfDefinedDomains(self) + return self.conn.numOfDefinedDomains() except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -331,7 +355,7 @@ class ConnectAPI(object): def numOfDomains(self): try: - return self.numOfDomains(self) + return self.conn.numOfDomains() except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -339,7 +363,39 @@ class ConnectAPI(object): def nwfilterLookupByUUID(self, uuid): try: - return self.nwfilterLookupByUUID(self, uuid) + return self.conn.nwfilterLookupByUUID(uuid) + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + + def change_begin(self, flag = 0): + try: + return self.conn.changeBegin(flag) + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + + def change_commit(self, flag = 0): + try: + return self.conn.changeCommit(flag) + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + + def change_rollback(self, flag = 0): + try: + return self.conn.changeRollback(flag) + except libvirt.libvirtError, e: + message = e.get_error_message() + code = e.get_error_code() + raise exception.LibvirtAPI(message, code) + + def suspend_for_duration(self, target, duration, flag = 0): + try: + return self.conn.suspendForDuration(target, duration, flag) except libvirt.libvirtError, e: message = e.get_error_message() code = e.get_error_code() @@ -348,3 +404,8 @@ class ConnectAPI(object): VIR_CRED_AUTHNAME = libvirt.VIR_CRED_AUTHNAME VIR_CRED_PASSPHRASE = libvirt.VIR_CRED_PASSPHRASE +# virNodeSuspendTarget +VIR_NODE_SUSPEND_TARGET_MEM = 0 +VIR_NODE_SUSPEND_TARGET_DISK = 1 +VIR_NODE_SUSPEND_TARGET_HYBRID = 2 +VIR_NODE_SUSPEND_TARGET_LAST = 3 -- 1.7.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list