mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-07-28 15:41:52 +03:00
Normalize white space
indent by 4 spaces one spaces around assignments Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
602
generator.py
602
generator.py
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
try:
|
try:
|
||||||
for cb,opaque in self.domainEventCallbacks.items():
|
for cb, opaque in self.domainEventCallbacks.items():
|
||||||
del self.domainEventCallbacks[cb]
|
del self.domainEventCallbacks[cb]
|
||||||
del self.domainEventCallbacks
|
del self.domainEventCallbacks
|
||||||
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self._o is not None:
|
if self._o is not None:
|
||||||
libvirtmod.virConnectClose(self._o)
|
libvirtmod.virConnectClose(self._o)
|
||||||
@ -25,7 +25,8 @@
|
|||||||
if len(self.domainEventCallbacks) == 0:
|
if len(self.domainEventCallbacks) == 0:
|
||||||
del self.domainEventCallbacks
|
del self.domainEventCallbacks
|
||||||
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
||||||
if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectDomainEventDeregister() failed', conn=self)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -35,15 +36,16 @@
|
|||||||
try:
|
try:
|
||||||
self.domainEventCallbacks[cb] = opaque
|
self.domainEventCallbacks[cb] = opaque
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
self.domainEventCallbacks = {cb:opaque}
|
self.domainEventCallbacks = {cb: opaque}
|
||||||
ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
|
ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
|
||||||
if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectDomainEventRegister() failed', conn=self)
|
||||||
|
|
||||||
def _dispatchDomainEventCallbacks(self, dom, event, detail):
|
def _dispatchDomainEventCallbacks(self, dom, event, detail):
|
||||||
"""Dispatches events to python user domain event callbacks
|
"""Dispatches events to python user domain event callbacks
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
for cb,opaque in self.domainEventCallbacks.items():
|
for cb, opaque in self.domainEventCallbacks.items():
|
||||||
cb(self, virDomain(self, _obj=dom), event, detail, opaque)
|
cb(self, virDomain(self, _obj=dom), event, detail, opaque)
|
||||||
return 0
|
return 0
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
@ -73,7 +75,7 @@
|
|||||||
cb = cbData["cb"]
|
cb = cbData["cb"]
|
||||||
opaque = cbData["opaque"]
|
opaque = cbData["opaque"]
|
||||||
|
|
||||||
cb(self, virDomain(self, _obj=dom), offset ,opaque)
|
cb(self, virDomain(self, _obj=dom), offset, opaque)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
|
def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
|
||||||
@ -108,8 +110,8 @@
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
|
def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
|
||||||
remoteAddr, authScheme, subject,
|
remoteAddr, authScheme, subject,
|
||||||
cbData):
|
cbData):
|
||||||
"""Dispatches events to python user domain graphics event callbacks
|
"""Dispatches events to python user domain graphics event callbacks
|
||||||
"""
|
"""
|
||||||
cb = cbData["cb"]
|
cb = cbData["cb"]
|
||||||
@ -272,7 +274,8 @@
|
|||||||
domain callback will disable delivery of this event type """
|
domain callback will disable delivery of this event type """
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
|
ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
|
||||||
if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectDomainEventDeregisterAny() failed', conn=self)
|
||||||
del self.domainEventCallbackID[callbackID]
|
del self.domainEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -291,7 +294,8 @@
|
|||||||
network callback will disable delivery of this event type"""
|
network callback will disable delivery of this event type"""
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod.virConnectNetworkEventDeregisterAny(self._o, callbackID)
|
ret = libvirtmod.virConnectNetworkEventDeregisterAny(self._o, callbackID)
|
||||||
if ret == -1: raise libvirtError ('virConnectNetworkEventDeregisterAny() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectNetworkEventDeregisterAny() failed', conn=self)
|
||||||
del self.networkEventCallbackID[callbackID]
|
del self.networkEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -301,13 +305,13 @@
|
|||||||
callback will enable delivery of the events"""
|
callback will enable delivery of the events"""
|
||||||
if not hasattr(self, 'networkEventCallbackID'):
|
if not hasattr(self, 'networkEventCallbackID'):
|
||||||
self.networkEventCallbackID = {}
|
self.networkEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
if net is None:
|
if net is None:
|
||||||
ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, None, eventID, cbData)
|
ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, None, eventID, cbData)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, net._o, eventID, cbData)
|
ret = libvirtmod.virConnectNetworkEventRegisterAny(self._o, net._o, eventID, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectNetworkEventRegisterAny() failed', conn=self)
|
raise libvirtError('virConnectNetworkEventRegisterAny() failed', conn=self)
|
||||||
self.networkEventCallbackID[ret] = opaque
|
self.networkEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -316,13 +320,13 @@
|
|||||||
callback will enable delivery of the events """
|
callback will enable delivery of the events """
|
||||||
if not hasattr(self, 'domainEventCallbackID'):
|
if not hasattr(self, 'domainEventCallbackID'):
|
||||||
self.domainEventCallbackID = {}
|
self.domainEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
if dom is None:
|
if dom is None:
|
||||||
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
|
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
|
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
|
raise libvirtError('virConnectDomainEventRegisterAny() failed', conn=self)
|
||||||
self.domainEventCallbackID[ret] = opaque
|
self.domainEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -351,7 +355,8 @@
|
|||||||
storage pool callback will disable delivery of this event type"""
|
storage pool callback will disable delivery of this event type"""
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod.virConnectStoragePoolEventDeregisterAny(self._o, callbackID)
|
ret = libvirtmod.virConnectStoragePoolEventDeregisterAny(self._o, callbackID)
|
||||||
if ret == -1: raise libvirtError ('virConnectStoragePoolEventDeregisterAny() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectStoragePoolEventDeregisterAny() failed', conn=self)
|
||||||
del self.storagePoolEventCallbackID[callbackID]
|
del self.storagePoolEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -361,13 +366,13 @@
|
|||||||
callback will enable delivery of the events"""
|
callback will enable delivery of the events"""
|
||||||
if not hasattr(self, 'storagePoolEventCallbackID'):
|
if not hasattr(self, 'storagePoolEventCallbackID'):
|
||||||
self.storagePoolEventCallbackID = {}
|
self.storagePoolEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
if pool is None:
|
if pool is None:
|
||||||
ret = libvirtmod.virConnectStoragePoolEventRegisterAny(self._o, None, eventID, cbData)
|
ret = libvirtmod.virConnectStoragePoolEventRegisterAny(self._o, None, eventID, cbData)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virConnectStoragePoolEventRegisterAny(self._o, pool._o, eventID, cbData)
|
ret = libvirtmod.virConnectStoragePoolEventRegisterAny(self._o, pool._o, eventID, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectStoragePoolEventRegisterAny() failed', conn=self)
|
raise libvirtError('virConnectStoragePoolEventRegisterAny() failed', conn=self)
|
||||||
self.storagePoolEventCallbackID[ret] = opaque
|
self.storagePoolEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -396,7 +401,8 @@
|
|||||||
node device callback will disable delivery of this event type"""
|
node device callback will disable delivery of this event type"""
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod.virConnectNodeDeviceEventDeregisterAny(self._o, callbackID)
|
ret = libvirtmod.virConnectNodeDeviceEventDeregisterAny(self._o, callbackID)
|
||||||
if ret == -1: raise libvirtError ('virConnectNodeDeviceEventDeregisterAny() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectNodeDeviceEventDeregisterAny() failed', conn=self)
|
||||||
del self.nodeDeviceEventCallbackID[callbackID]
|
del self.nodeDeviceEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -406,13 +412,13 @@
|
|||||||
callback will enable delivery of the events"""
|
callback will enable delivery of the events"""
|
||||||
if not hasattr(self, 'nodeDeviceEventCallbackID'):
|
if not hasattr(self, 'nodeDeviceEventCallbackID'):
|
||||||
self.nodeDeviceEventCallbackID = {}
|
self.nodeDeviceEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
if dev is None:
|
if dev is None:
|
||||||
ret = libvirtmod.virConnectNodeDeviceEventRegisterAny(self._o, None, eventID, cbData)
|
ret = libvirtmod.virConnectNodeDeviceEventRegisterAny(self._o, None, eventID, cbData)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virConnectNodeDeviceEventRegisterAny(self._o, dev._o, eventID, cbData)
|
ret = libvirtmod.virConnectNodeDeviceEventRegisterAny(self._o, dev._o, eventID, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectNodeDeviceEventRegisterAny() failed', conn=self)
|
raise libvirtError('virConnectNodeDeviceEventRegisterAny() failed', conn=self)
|
||||||
self.nodeDeviceEventCallbackID[ret] = opaque
|
self.nodeDeviceEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -439,7 +445,8 @@
|
|||||||
secret callback will disable delivery of this event type"""
|
secret callback will disable delivery of this event type"""
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod.virConnectSecretEventDeregisterAny(self._o, callbackID)
|
ret = libvirtmod.virConnectSecretEventDeregisterAny(self._o, callbackID)
|
||||||
if ret == -1: raise libvirtError ('virConnectSecretEventDeregisterAny() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectSecretEventDeregisterAny() failed', conn=self)
|
||||||
del self.secretEventCallbackID[callbackID]
|
del self.secretEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
@ -449,13 +456,13 @@
|
|||||||
callback will enable delivery of the events"""
|
callback will enable delivery of the events"""
|
||||||
if not hasattr(self, 'secretEventCallbackID'):
|
if not hasattr(self, 'secretEventCallbackID'):
|
||||||
self.secretEventCallbackID = {}
|
self.secretEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
if secret is None:
|
if secret is None:
|
||||||
ret = libvirtmod.virConnectSecretEventRegisterAny(self._o, None, eventID, cbData)
|
ret = libvirtmod.virConnectSecretEventRegisterAny(self._o, None, eventID, cbData)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virConnectSecretEventRegisterAny(self._o, secret._o, eventID, cbData)
|
ret = libvirtmod.virConnectSecretEventRegisterAny(self._o, secret._o, eventID, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectSecretEventRegisterAny() failed', conn=self)
|
raise libvirtError('virConnectSecretEventRegisterAny() failed', conn=self)
|
||||||
self.secretEventCallbackID[ret] = opaque
|
self.secretEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -563,19 +570,19 @@
|
|||||||
cb(self, reason, opaque)
|
cb(self, reason, opaque)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def unregisterCloseCallback(self):
|
def unregisterCloseCallback(self):
|
||||||
"""Removes a close event callback"""
|
"""Removes a close event callback"""
|
||||||
ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
|
ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
|
||||||
if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virConnectUnregisterCloseCallback() failed', conn=self)
|
||||||
|
|
||||||
def registerCloseCallback(self, cb, opaque):
|
def registerCloseCallback(self, cb, opaque):
|
||||||
"""Adds a close event callback, providing a notification
|
"""Adds a close event callback, providing a notification
|
||||||
when a connection fails / closes"""
|
when a connection fails / closes"""
|
||||||
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
cbData = {"cb": cb, "conn": self, "opaque": opaque}
|
||||||
ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
|
ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
|
raise libvirtError('virConnectRegisterCloseCallback() failed', conn=self)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def createXMLWithFiles(self, xmlDesc, files, flags=0):
|
def createXMLWithFiles(self, xmlDesc, files, flags=0):
|
||||||
@ -604,11 +611,12 @@
|
|||||||
libvirtd daemon. Any domains marked for auto destroy will
|
libvirtd daemon. Any domains marked for auto destroy will
|
||||||
block attempts at migration, save-to-file, or snapshots. """
|
block attempts at migration, save-to-file, or snapshots. """
|
||||||
ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
|
ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
|
||||||
if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
|
if ret is None:
|
||||||
__tmp = virDomain(self,_obj=ret)
|
raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
|
||||||
|
__tmp = virDomain(self, _obj=ret)
|
||||||
return __tmp
|
return __tmp
|
||||||
|
|
||||||
def getAllDomainStats(self, stats = 0, flags=0):
|
def getAllDomainStats(self, stats=0, flags=0):
|
||||||
"""Query statistics for all domains on a given connection.
|
"""Query statistics for all domains on a given connection.
|
||||||
|
|
||||||
Report statistics of various parameters for a running VM according to @stats
|
Report statistics of various parameters for a running VM according to @stats
|
||||||
@ -656,7 +664,7 @@
|
|||||||
|
|
||||||
retlist = list()
|
retlist = list()
|
||||||
for elem in ret:
|
for elem in ret:
|
||||||
record = (virDomain(self, _obj=elem[0]) , elem[1])
|
record = (virDomain(self, _obj=elem[0]), elem[1])
|
||||||
retlist.append(record)
|
retlist.append(record)
|
||||||
|
|
||||||
return retlist
|
return retlist
|
||||||
@ -703,7 +711,7 @@
|
|||||||
|
|
||||||
retlist = list()
|
retlist = list()
|
||||||
for elem in ret:
|
for elem in ret:
|
||||||
record = (virDomain(self, _obj=elem[0]) , elem[1])
|
record = (virDomain(self, _obj=elem[0]), elem[1])
|
||||||
retlist.append(record)
|
retlist.append(record)
|
||||||
|
|
||||||
return retlist
|
return retlist
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
return retlist
|
return retlist
|
||||||
|
|
||||||
|
|
||||||
def listAllCheckpoints(self, flags=0):
|
def listAllCheckpoints(self, flags=0):
|
||||||
"""List all checkpoints and returns a list of checkpoint objects"""
|
"""List all checkpoints and returns a list of checkpoint objects"""
|
||||||
ret = libvirtmod.virDomainListAllCheckpoints(self._o, flags)
|
ret = libvirtmod.virDomainListAllCheckpoints(self._o, flags)
|
||||||
@ -23,7 +22,6 @@
|
|||||||
|
|
||||||
return retlist
|
return retlist
|
||||||
|
|
||||||
|
|
||||||
def createWithFiles(self, files, flags=0):
|
def createWithFiles(self, files, flags=0):
|
||||||
"""Launch a defined domain. If the call succeeds the domain moves from the
|
"""Launch a defined domain. If the call succeeds the domain moves from the
|
||||||
defined to the running domains pools.
|
defined to the running domains pools.
|
||||||
@ -58,30 +56,35 @@
|
|||||||
If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
|
If the VIR_DOMAIN_START_FORCE_BOOT flag is set, then any managed save
|
||||||
file for this domain is discarded, and the domain boots from scratch. """
|
file for this domain is discarded, and the domain boots from scratch. """
|
||||||
ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
|
ret = libvirtmod.virDomainCreateWithFiles(self._o, files, flags)
|
||||||
if ret == -1: raise libvirtError ('virDomainCreateWithFiles() failed', dom=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virDomainCreateWithFiles() failed', dom=self)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def fsFreeze(self, mountpoints=None, flags=0):
|
def fsFreeze(self, mountpoints=None, flags=0):
|
||||||
"""Freeze specified filesystems within the guest """
|
"""Freeze specified filesystems within the guest """
|
||||||
ret = libvirtmod.virDomainFSFreeze(self._o, mountpoints, flags)
|
ret = libvirtmod.virDomainFSFreeze(self._o, mountpoints, flags)
|
||||||
if ret == -1: raise libvirtError ('virDomainFSFreeze() failed', dom=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virDomainFSFreeze() failed', dom=self)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def fsThaw(self, mountpoints=None, flags=0):
|
def fsThaw(self, mountpoints=None, flags=0):
|
||||||
"""Thaw specified filesystems within the guest """
|
"""Thaw specified filesystems within the guest """
|
||||||
ret = libvirtmod.virDomainFSThaw(self._o, mountpoints, flags)
|
ret = libvirtmod.virDomainFSThaw(self._o, mountpoints, flags)
|
||||||
if ret == -1: raise libvirtError ('virDomainFSThaw() failed', dom=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virDomainFSThaw() failed', dom=self)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def getTime(self, flags=0):
|
def getTime(self, flags=0):
|
||||||
"""Extract information about guest time """
|
"""Extract information about guest time """
|
||||||
ret = libvirtmod.virDomainGetTime(self._o, flags)
|
ret = libvirtmod.virDomainGetTime(self._o, flags)
|
||||||
if ret == None: raise libvirtError ('virDomainGetTime() failed', dom=self)
|
if ret == None:
|
||||||
|
raise libvirtError('virDomainGetTime() failed', dom=self)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def setTime(self, time=None, flags=0):
|
def setTime(self, time=None, flags=0):
|
||||||
"""Set guest time to the given value. @time is a dict containing
|
"""Set guest time to the given value. @time is a dict containing
|
||||||
'seconds' field for seconds and 'nseconds' field for nanoseconds """
|
'seconds' field for seconds and 'nseconds' field for nanoseconds """
|
||||||
ret = libvirtmod.virDomainSetTime(self._o, time, flags)
|
ret = libvirtmod.virDomainSetTime(self._o, time, flags)
|
||||||
if ret == -1: raise libvirtError ('virDomainSetTime() failed', dom=self)
|
if ret == -1:
|
||||||
|
raise libvirtError('virDomainSetTime() failed', dom=self)
|
||||||
return ret
|
return ret
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
if self.cb:
|
if self.cb:
|
||||||
libvirtmod.virStreamEventRemoveCallback(self._o)
|
libvirtmod.virStreamEventRemoveCallback(self._o)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self._o is not None:
|
if self._o is not None:
|
||||||
libvirtmod.virStreamFree(self._o)
|
libvirtmod.virStreamFree(self._o)
|
||||||
@ -21,9 +21,10 @@
|
|||||||
|
|
||||||
def eventAddCallback(self, events, cb, opaque):
|
def eventAddCallback(self, events, cb, opaque):
|
||||||
self.cb = cb
|
self.cb = cb
|
||||||
cbData = {"stream": self, "cb" : cb, "opaque" : opaque}
|
cbData = {"stream": self, "cb": cb, "opaque": opaque}
|
||||||
ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
|
ret = libvirtmod.virStreamEventAddCallback(self._o, events, cbData)
|
||||||
if ret == -1: raise libvirtError ('virStreamEventAddCallback() failed')
|
if ret == -1:
|
||||||
|
raise libvirtError('virStreamEventAddCallback() failed')
|
||||||
|
|
||||||
def recvAll(self, handler, opaque):
|
def recvAll(self, handler, opaque):
|
||||||
"""Receive the entire data stream, sending the data to the
|
"""Receive the entire data stream, sending the data to the
|
||||||
@ -105,7 +106,8 @@
|
|||||||
the request would block, integer -2 is returned.
|
the request would block, integer -2 is returned.
|
||||||
"""
|
"""
|
||||||
ret = libvirtmod.virStreamRecv(self._o, nbytes)
|
ret = libvirtmod.virStreamRecv(self._o, nbytes)
|
||||||
if ret is None: raise libvirtError ('virStreamRecv() failed')
|
if ret is None:
|
||||||
|
raise libvirtError('virStreamRecv() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
@ -123,20 +125,22 @@
|
|||||||
subsequent call.
|
subsequent call.
|
||||||
"""
|
"""
|
||||||
ret = libvirtmod.virStreamSend(self._o, data)
|
ret = libvirtmod.virStreamSend(self._o, data)
|
||||||
if ret == -1: raise libvirtError ('virStreamSend() failed')
|
if ret == -1:
|
||||||
|
raise libvirtError('virStreamSend() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def recvHole(self, flags = 0):
|
def recvHole(self, flags=0):
|
||||||
"""This method is used to determine the length in bytes
|
"""This method is used to determine the length in bytes
|
||||||
of the empty space to be created in a stream's target
|
of the empty space to be created in a stream's target
|
||||||
file when uploading or downloading sparsely populated
|
file when uploading or downloading sparsely populated
|
||||||
files. This is the counterpart to sendHole.
|
files. This is the counterpart to sendHole.
|
||||||
"""
|
"""
|
||||||
ret = libvirtmod.virStreamRecvHole(self._o, flags)
|
ret = libvirtmod.virStreamRecvHole(self._o, flags)
|
||||||
if ret is None: raise libvirtError ('virStreamRecvHole() failed')
|
if ret is None:
|
||||||
|
raise libvirtError('virStreamRecvHole() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def sendHole(self, length, flags = 0):
|
def sendHole(self, length, flags=0):
|
||||||
"""Rather than transmitting empty file space, this method
|
"""Rather than transmitting empty file space, this method
|
||||||
directs the stream target to create length bytes of empty
|
directs the stream target to create length bytes of empty
|
||||||
space. This method would be used when uploading or
|
space. This method would be used when uploading or
|
||||||
@ -144,10 +148,11 @@
|
|||||||
needless copy of empty file space.
|
needless copy of empty file space.
|
||||||
"""
|
"""
|
||||||
ret = libvirtmod.virStreamSendHole(self._o, length, flags)
|
ret = libvirtmod.virStreamSendHole(self._o, length, flags)
|
||||||
if ret == -1: raise libvirtError('virStreamSendHole() failed')
|
if ret == -1:
|
||||||
|
raise libvirtError('virStreamSendHole() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def recvFlags(self, nbytes, flags = 0):
|
def recvFlags(self, nbytes, flags=0):
|
||||||
"""Reads a series of bytes from the stream. This method may
|
"""Reads a series of bytes from the stream. This method may
|
||||||
block the calling application for an arbitrary amount
|
block the calling application for an arbitrary amount
|
||||||
of time. This is just like recv except it has flags
|
of time. This is just like recv except it has flags
|
||||||
@ -162,7 +167,8 @@
|
|||||||
the request would block, integer -2 is returned.
|
the request would block, integer -2 is returned.
|
||||||
"""
|
"""
|
||||||
ret = libvirtmod.virStreamRecvFlags(self._o, nbytes, flags)
|
ret = libvirtmod.virStreamRecvFlags(self._o, nbytes, flags)
|
||||||
if ret is None: raise libvirtError ('virStreamRecvFlags() failed')
|
if ret is None:
|
||||||
|
raise libvirtError('virStreamRecvFlags() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def sparseRecvAll(self, handler, holeHandler, opaque):
|
def sparseRecvAll(self, handler, holeHandler, opaque):
|
||||||
|
@ -78,6 +78,7 @@ class libvirtError(Exception):
|
|||||||
return None
|
return None
|
||||||
return self.err[8]
|
return self.err[8]
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# register the libvirt global error handler
|
# register the libvirt global error handler
|
||||||
#
|
#
|
||||||
@ -86,18 +87,20 @@ def registerErrorHandler(f, ctx):
|
|||||||
The function is called back as f(ctx, error), with error
|
The function is called back as f(ctx, error), with error
|
||||||
being a list of information about the error being raised.
|
being a list of information about the error being raised.
|
||||||
Returns 1 in case of success."""
|
Returns 1 in case of success."""
|
||||||
return libvirtmod.virRegisterErrorHandler(f,ctx)
|
return libvirtmod.virRegisterErrorHandler(f, ctx)
|
||||||
|
|
||||||
|
|
||||||
def openAuth(uri, auth, flags=0):
|
def openAuth(uri, auth, flags=0):
|
||||||
ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
|
ret = libvirtmod.virConnectOpenAuth(uri, auth, flags)
|
||||||
if ret is None:raise libvirtError('virConnectOpenAuth() failed')
|
if ret is None:
|
||||||
|
raise libvirtError('virConnectOpenAuth() failed')
|
||||||
return virConnect(_obj=ret)
|
return virConnect(_obj=ret)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Return library version.
|
# Return library version.
|
||||||
#
|
#
|
||||||
def getVersion (name = None):
|
def getVersion(name=None):
|
||||||
"""If no name parameter is passed (or name is None) then the
|
"""If no name parameter is passed (or name is None) then the
|
||||||
version of the libvirt library is returned as an integer.
|
version of the libvirt library is returned as an integer.
|
||||||
|
|
||||||
@ -110,10 +113,11 @@ def getVersion (name = None):
|
|||||||
|
|
||||||
Versions numbers are integers: 1000000*major + 1000*minor + release."""
|
Versions numbers are integers: 1000000*major + 1000*minor + release."""
|
||||||
if name is None:
|
if name is None:
|
||||||
ret = libvirtmod.virGetVersion ()
|
ret = libvirtmod.virGetVersion()
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod.virGetVersion (name)
|
ret = libvirtmod.virGetVersion(name)
|
||||||
if ret is None: raise libvirtError ("virGetVersion() failed")
|
if ret is None:
|
||||||
|
raise libvirtError("virGetVersion() failed")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@ -137,6 +141,7 @@ def _eventInvokeHandleCallback(watch, fd, event, opaque, opaquecompat=None):
|
|||||||
|
|
||||||
libvirtmod.virEventInvokeHandleCallback(watch, fd, event, callback, opaque)
|
libvirtmod.virEventInvokeHandleCallback(watch, fd, event, callback, opaque)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Invoke an EventTimeout callback
|
# Invoke an EventTimeout callback
|
||||||
#
|
#
|
||||||
@ -157,6 +162,7 @@ def _eventInvokeTimeoutCallback(timer, opaque, opaquecompat=None):
|
|||||||
|
|
||||||
libvirtmod.virEventInvokeTimeoutCallback(timer, callback, opaque)
|
libvirtmod.virEventInvokeTimeoutCallback(timer, callback, opaque)
|
||||||
|
|
||||||
|
|
||||||
def _dispatchEventHandleCallback(watch, fd, events, cbData):
|
def _dispatchEventHandleCallback(watch, fd, events, cbData):
|
||||||
cb = cbData["cb"]
|
cb = cbData["cb"]
|
||||||
opaque = cbData["opaque"]
|
opaque = cbData["opaque"]
|
||||||
@ -164,6 +170,7 @@ def _dispatchEventHandleCallback(watch, fd, events, cbData):
|
|||||||
cb(watch, fd, events, opaque)
|
cb(watch, fd, events, opaque)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def _dispatchEventTimeoutCallback(timer, cbData):
|
def _dispatchEventTimeoutCallback(timer, cbData):
|
||||||
cb = cbData["cb"]
|
cb = cbData["cb"]
|
||||||
opaque = cbData["opaque"]
|
opaque = cbData["opaque"]
|
||||||
@ -171,6 +178,7 @@ def _dispatchEventTimeoutCallback(timer, cbData):
|
|||||||
cb(timer, opaque)
|
cb(timer, opaque)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def virEventAddHandle(fd, events, cb, opaque):
|
def virEventAddHandle(fd, events, cb, opaque):
|
||||||
"""
|
"""
|
||||||
register a callback for monitoring file handle events
|
register a callback for monitoring file handle events
|
||||||
@ -186,11 +194,13 @@ def virEventAddHandle(fd, events, cb, opaque):
|
|||||||
events, # int bitmap of events that have occurred
|
events, # int bitmap of events that have occurred
|
||||||
opaque): # opaque data passed to eventAddHandle
|
opaque): # opaque data passed to eventAddHandle
|
||||||
"""
|
"""
|
||||||
cbData = {"cb" : cb, "opaque" : opaque}
|
cbData = {"cb": cb, "opaque": opaque}
|
||||||
ret = libvirtmod.virEventAddHandle(fd, events, cbData)
|
ret = libvirtmod.virEventAddHandle(fd, events, cbData)
|
||||||
if ret == -1: raise libvirtError ('virEventAddHandle() failed')
|
if ret == -1:
|
||||||
|
raise libvirtError('virEventAddHandle() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def virEventAddTimeout(timeout, cb, opaque):
|
def virEventAddTimeout(timeout, cb, opaque):
|
||||||
"""
|
"""
|
||||||
register a callback for a timer event
|
register a callback for a timer event
|
||||||
@ -206,9 +216,10 @@ def virEventAddTimeout(timeout, cb, opaque):
|
|||||||
def cb(timer, # int id of the timer
|
def cb(timer, # int id of the timer
|
||||||
opaque): # opaque data passed to eventAddTimeout
|
opaque): # opaque data passed to eventAddTimeout
|
||||||
"""
|
"""
|
||||||
cbData = {"cb" : cb, "opaque" : opaque}
|
cbData = {"cb": cb, "opaque": opaque}
|
||||||
ret = libvirtmod.virEventAddTimeout(timeout, cbData)
|
ret = libvirtmod.virEventAddTimeout(timeout, cbData)
|
||||||
if ret == -1: raise libvirtError ('virEventAddTimeout() failed')
|
if ret == -1:
|
||||||
|
raise libvirtError('virEventAddTimeout() failed')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Manually written part of python bindings for libvirt-qemu
|
# Manually written part of python bindings for libvirt-qemu
|
||||||
|
|
||||||
|
|
||||||
def _dispatchQemuMonitorEventCallback(conn, dom, event, seconds, micros, details, cbData):
|
def _dispatchQemuMonitorEventCallback(conn, dom, event, seconds, micros, details, cbData):
|
||||||
"""Dispatches events to python user qemu monitor event callbacks
|
"""Dispatches events to python user qemu monitor event callbacks
|
||||||
"""
|
"""
|
||||||
@ -9,27 +10,30 @@ def _dispatchQemuMonitorEventCallback(conn, dom, event, seconds, micros, details
|
|||||||
cb(conn, libvirt.virDomain(conn, _obj=dom), event, seconds, micros, details, opaque)
|
cb(conn, libvirt.virDomain(conn, _obj=dom), event, seconds, micros, details, opaque)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def qemuMonitorEventDeregister(conn, callbackID):
|
def qemuMonitorEventDeregister(conn, callbackID):
|
||||||
"""Removes a qemu monitor event callback. De-registering for a callback
|
"""Removes a qemu monitor event callback. De-registering for a callback
|
||||||
will disable delivery of this event type"""
|
will disable delivery of this event type"""
|
||||||
try:
|
try:
|
||||||
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventDeregister(conn._o, callbackID)
|
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventDeregister(conn._o, callbackID)
|
||||||
if ret == -1: raise libvirt.libvirtError ('virConnectDomainQemuMonitorEventDeregister() failed')
|
if ret == -1:
|
||||||
|
raise libvirt.libvirtError('virConnectDomainQemuMonitorEventDeregister() failed')
|
||||||
del conn.qemuMonitorEventCallbackID[callbackID]
|
del conn.qemuMonitorEventCallbackID[callbackID]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def qemuMonitorEventRegister(conn, dom, event, cb, opaque, flags=0):
|
def qemuMonitorEventRegister(conn, dom, event, cb, opaque, flags=0):
|
||||||
"""Adds a qemu monitor event callback. Registering for a monitor
|
"""Adds a qemu monitor event callback. Registering for a monitor
|
||||||
callback will enable delivery of the events"""
|
callback will enable delivery of the events"""
|
||||||
if not hasattr(conn, 'qemuMonitorEventCallbackID'):
|
if not hasattr(conn, 'qemuMonitorEventCallbackID'):
|
||||||
conn.qemuMonitorEventCallbackID = {}
|
conn.qemuMonitorEventCallbackID = {}
|
||||||
cbData = { "cb": cb, "conn": conn, "opaque": opaque }
|
cbData = {"cb": cb, "conn": conn, "opaque": opaque}
|
||||||
if dom is None:
|
if dom is None:
|
||||||
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, None, event, cbData, flags)
|
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, None, event, cbData, flags)
|
||||||
else:
|
else:
|
||||||
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, dom._o, event, cbData, flags)
|
ret = libvirtmod_qemu.virConnectDomainQemuMonitorEventRegister(conn._o, dom._o, event, cbData, flags)
|
||||||
if ret == -1:
|
if ret == -1:
|
||||||
raise libvirt.libvirtError ('virConnectDomainQemuMonitorEventRegister() failed')
|
raise libvirt.libvirtError('virConnectDomainQemuMonitorEventRegister() failed')
|
||||||
conn.qemuMonitorEventCallbackID[ret] = opaque
|
conn.qemuMonitorEventCallbackID[ret] = opaque
|
||||||
return ret
|
return ret
|
||||||
|
@ -78,6 +78,7 @@ class Callback(object):
|
|||||||
self.impl.log.debug('callback %d close(), scheduling ff', self.iden)
|
self.impl.log.debug('callback %d close(), scheduling ff', self.iden)
|
||||||
self.impl.schedule_ff_callback(self.iden, self.opaque)
|
self.impl.schedule_ff_callback(self.iden, self.opaque)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# file descriptors
|
# file descriptors
|
||||||
#
|
#
|
||||||
@ -114,8 +115,8 @@ class Descriptor(object):
|
|||||||
|
|
||||||
# For the edge case of empty callbacks, any() returns False.
|
# For the edge case of empty callbacks, any() returns False.
|
||||||
if any(callback.event & ~(
|
if any(callback.event & ~(
|
||||||
libvirt.VIR_EVENT_HANDLE_READABLE |
|
libvirt.VIR_EVENT_HANDLE_READABLE |
|
||||||
libvirt.VIR_EVENT_HANDLE_WRITABLE)
|
libvirt.VIR_EVENT_HANDLE_WRITABLE)
|
||||||
for callback in self.callbacks.values()):
|
for callback in self.callbacks.values()):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'The only event supported are VIR_EVENT_HANDLE_READABLE '
|
'The only event supported are VIR_EVENT_HANDLE_READABLE '
|
||||||
@ -161,6 +162,7 @@ class Descriptor(object):
|
|||||||
self.update()
|
self.update()
|
||||||
return callback
|
return callback
|
||||||
|
|
||||||
|
|
||||||
class DescriptorDict(dict):
|
class DescriptorDict(dict):
|
||||||
'''Descriptors collection
|
'''Descriptors collection
|
||||||
|
|
||||||
@ -175,6 +177,7 @@ class DescriptorDict(dict):
|
|||||||
self[fd] = descriptor
|
self[fd] = descriptor
|
||||||
return descriptor
|
return descriptor
|
||||||
|
|
||||||
|
|
||||||
class FDCallback(Callback):
|
class FDCallback(Callback):
|
||||||
'''Callback for file descriptor (watcher)
|
'''Callback for file descriptor (watcher)
|
||||||
|
|
||||||
@ -197,6 +200,7 @@ class FDCallback(Callback):
|
|||||||
self.event = event
|
self.event = event
|
||||||
self.descriptor.update()
|
self.descriptor.update()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# timeouts
|
# timeouts
|
||||||
#
|
#
|
||||||
@ -242,7 +246,7 @@ class TimeoutCallback(Callback):
|
|||||||
if self.timeout >= 0 and self._task is None:
|
if self.timeout >= 0 and self._task is None:
|
||||||
self.impl.log.debug('timer %r start', self.iden)
|
self.impl.log.debug('timer %r start', self.iden)
|
||||||
self._task = ensure_future(self._timer(),
|
self._task = ensure_future(self._timer(),
|
||||||
loop=self.impl.loop)
|
loop=self.impl.loop)
|
||||||
|
|
||||||
elif self.timeout < 0 and self._task is not None:
|
elif self.timeout < 0 and self._task is not None:
|
||||||
self.impl.log.debug('timer %r stop', self.iden)
|
self.impl.log.debug('timer %r stop', self.iden)
|
||||||
@ -254,6 +258,7 @@ class TimeoutCallback(Callback):
|
|||||||
self.update(timeout=-1)
|
self.update(timeout=-1)
|
||||||
super(TimeoutCallback, self).close()
|
super(TimeoutCallback, self).close()
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# main implementation
|
# main implementation
|
||||||
#
|
#
|
||||||
@ -298,7 +303,7 @@ class virEventAsyncIOImpl(object):
|
|||||||
# pylint: disable=bad-whitespace
|
# pylint: disable=bad-whitespace
|
||||||
self.log.debug('register()')
|
self.log.debug('register()')
|
||||||
libvirt.virEventRegisterImpl(
|
libvirt.virEventRegisterImpl(
|
||||||
self._add_handle, self._update_handle, self._remove_handle,
|
self._add_handle, self._update_handle, self._remove_handle,
|
||||||
self._add_timeout, self._update_timeout, self._remove_timeout)
|
self._add_timeout, self._update_timeout, self._remove_timeout)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -350,11 +355,11 @@ class virEventAsyncIOImpl(object):
|
|||||||
https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddHandleFuncFunc
|
https://libvirt.org/html/libvirt-libvirt-event.html#virEventAddHandleFuncFunc
|
||||||
'''
|
'''
|
||||||
callback = FDCallback(self, cb, opaque,
|
callback = FDCallback(self, cb, opaque,
|
||||||
descriptor=self.descriptors[fd], event=event)
|
descriptor=self.descriptors[fd], event=event)
|
||||||
assert callback.iden not in self.callbacks
|
assert callback.iden not in self.callbacks
|
||||||
|
|
||||||
self.log.debug('add_handle(fd=%d, event=%d, cb=..., opaque=...) = %d',
|
self.log.debug('add_handle(fd=%d, event=%d, cb=..., opaque=...) = %d',
|
||||||
fd, event, callback.iden)
|
fd, event, callback.iden)
|
||||||
self.callbacks[callback.iden] = callback
|
self.callbacks[callback.iden] = callback
|
||||||
self.descriptors[fd].add_handle(callback)
|
self.descriptors[fd].add_handle(callback)
|
||||||
self._pending_inc()
|
self._pending_inc()
|
||||||
@ -410,7 +415,7 @@ class virEventAsyncIOImpl(object):
|
|||||||
assert callback.iden not in self.callbacks
|
assert callback.iden not in self.callbacks
|
||||||
|
|
||||||
self.log.debug('add_timeout(timeout=%d, cb=..., opaque=...) = %d',
|
self.log.debug('add_timeout(timeout=%d, cb=..., opaque=...) = %d',
|
||||||
timeout, callback.iden)
|
timeout, callback.iden)
|
||||||
self.callbacks[callback.iden] = callback
|
self.callbacks[callback.iden] = callback
|
||||||
callback.update(timeout=timeout)
|
callback.update(timeout=timeout)
|
||||||
self._pending_inc()
|
self._pending_inc()
|
||||||
@ -448,10 +453,13 @@ class virEventAsyncIOImpl(object):
|
|||||||
|
|
||||||
|
|
||||||
_current_impl = None
|
_current_impl = None
|
||||||
|
|
||||||
|
|
||||||
def getCurrentImpl():
|
def getCurrentImpl():
|
||||||
'''Return the current implementation, or None if not yet registered'''
|
'''Return the current implementation, or None if not yet registered'''
|
||||||
return _current_impl
|
return _current_impl
|
||||||
|
|
||||||
|
|
||||||
def virEventRegisterAsyncIOImpl(loop=None):
|
def virEventRegisterAsyncIOImpl(loop=None):
|
||||||
'''Arrange for libvirt's callbacks to be dispatched via asyncio event loop
|
'''Arrange for libvirt's callbacks to be dispatched via asyncio event loop
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ def get_libvirt_api_xml_path():
|
|||||||
sys.exit(proc.returncode)
|
sys.exit(proc.returncode)
|
||||||
return stdout.splitlines()[0]
|
return stdout.splitlines()[0]
|
||||||
|
|
||||||
|
|
||||||
# Path to the libvirt API XML file
|
# Path to the libvirt API XML file
|
||||||
if len(sys.argv) >= 3:
|
if len(sys.argv) >= 3:
|
||||||
xml = sys.argv[2]
|
xml = sys.argv[2]
|
||||||
@ -96,7 +97,7 @@ for n in set:
|
|||||||
# Phase 2: Identify all classes and methods in the 'libvirt' python module
|
# Phase 2: Identify all classes and methods in the 'libvirt' python module
|
||||||
gotenums = []
|
gotenums = []
|
||||||
gottypes = []
|
gottypes = []
|
||||||
gotfunctions = { "libvirt": [] }
|
gotfunctions = {"libvirt": []}
|
||||||
|
|
||||||
for name in dir(libvirt):
|
for name in dir(libvirt):
|
||||||
if name[0] == '_':
|
if name[0] == '_':
|
||||||
@ -188,7 +189,6 @@ for cname in wantfunctions:
|
|||||||
name.endswith("Callback")):
|
name.endswith("Callback")):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
# virEvent APIs go into main 'libvirt' namespace not any class
|
# virEvent APIs go into main 'libvirt' namespace not any class
|
||||||
if name[0:8] == "virEvent":
|
if name[0:8] == "virEvent":
|
||||||
if name[-4:] == "Func":
|
if name[-4:] == "Func":
|
||||||
@ -231,7 +231,6 @@ for name in sorted(basicklassmap):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
# All the error handling methods need special handling
|
# All the error handling methods need special handling
|
||||||
if klass == "libvirt":
|
if klass == "libvirt":
|
||||||
if func in ["CopyLastError", "DefaultErrorFunc",
|
if func in ["CopyLastError", "DefaultErrorFunc",
|
||||||
@ -264,7 +263,7 @@ for name in sorted(basicklassmap):
|
|||||||
"LookupByUUIDString", "LookupByVolume" "LookupByName",
|
"LookupByUUIDString", "LookupByVolume" "LookupByName",
|
||||||
"LookupByID", "LookupByName", "LookupByKey", "LookupByPath",
|
"LookupByID", "LookupByName", "LookupByKey", "LookupByPath",
|
||||||
"LookupByMACString", "LookupByUsage", "LookupByVolume",
|
"LookupByMACString", "LookupByUsage", "LookupByVolume",
|
||||||
"LookupByTargetPath","LookupSCSIHostByWWN", "LookupByPortDev",
|
"LookupByTargetPath", "LookupSCSIHostByWWN", "LookupByPortDev",
|
||||||
"Restore", "RestoreFlags",
|
"Restore", "RestoreFlags",
|
||||||
"SaveImageDefineXML", "SaveImageGetXMLDesc", "DefineXMLFlags"]:
|
"SaveImageDefineXML", "SaveImageGetXMLDesc", "DefineXMLFlags"]:
|
||||||
if klass != "virDomain":
|
if klass != "virDomain":
|
||||||
@ -386,7 +385,7 @@ for name in sorted(finalklassmap):
|
|||||||
# These exist in C and exist in python, but we've got
|
# These exist in C and exist in python, but we've got
|
||||||
# a pure-python impl so don't check them
|
# a pure-python impl so don't check them
|
||||||
if name in ["virStreamRecvAll", "virStreamSendAll",
|
if name in ["virStreamRecvAll", "virStreamSendAll",
|
||||||
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
"virStreamSparseRecvAll", "virStreamSparseSendAll"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import libvirt
|
import libvirt
|
||||||
|
|
||||||
|
|
||||||
class TestLibvirtConn(unittest.TestCase):
|
class TestLibvirtConn(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = libvirt.open("test:///default")
|
self.conn = libvirt.open("test:///default")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import libvirt
|
import libvirt
|
||||||
|
|
||||||
|
|
||||||
class TestLibvirtDomain(unittest.TestCase):
|
class TestLibvirtDomain(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.conn = libvirt.open("test:///default")
|
self.conn = libvirt.open("test:///default")
|
||||||
|
Reference in New Issue
Block a user