2008-10-31 13:56:47 +00:00
|
|
|
def __del__(self):
|
|
|
|
try:
|
|
|
|
for cb,opaque in self.domainEventCallbacks.items():
|
|
|
|
del self.domainEventCallbacks[cb]
|
2010-07-13 08:54:26 +00:00
|
|
|
del self.domainEventCallbacks
|
2008-10-31 13:56:47 +00:00
|
|
|
libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
2013-08-22 09:16:03 +00:00
|
|
|
if self._o is not None:
|
2008-10-31 13:56:47 +00:00
|
|
|
libvirtmod.virConnectClose(self._o)
|
|
|
|
self._o = None
|
|
|
|
|
|
|
|
def domainEventDeregister(self, cb):
|
|
|
|
"""Removes a Domain Event Callback. De-registering for a
|
|
|
|
domain callback will disable delivery of this event type """
|
|
|
|
try:
|
|
|
|
del self.domainEventCallbacks[cb]
|
|
|
|
if len(self.domainEventCallbacks) == 0:
|
2010-07-13 08:54:26 +00:00
|
|
|
del self.domainEventCallbacks
|
2008-10-31 13:56:47 +00:00
|
|
|
ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
|
|
|
|
if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def domainEventRegister(self, cb, opaque):
|
|
|
|
"""Adds a Domain Event Callback. Registering for a domain
|
|
|
|
callback will enable delivery of the events """
|
|
|
|
try:
|
|
|
|
self.domainEventCallbacks[cb] = opaque
|
|
|
|
except AttributeError:
|
|
|
|
self.domainEventCallbacks = {cb:opaque}
|
|
|
|
ret = libvirtmod.virConnectDomainEventRegister(self._o, self)
|
|
|
|
if ret == -1: raise libvirtError ('virConnectDomainEventRegister() failed', conn=self)
|
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventCallbacks(self, dom, event, detail):
|
2008-10-31 13:56:47 +00:00
|
|
|
"""Dispatches events to python user domain event callbacks
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
for cb,opaque in self.domainEventCallbacks.items():
|
2008-11-24 19:28:12 +00:00
|
|
|
cb(self,dom,event,detail,opaque)
|
2008-10-31 13:56:47 +00:00
|
|
|
return 0
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2010-03-26 13:22:06 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventLifecycleCallback(self, dom, event, detail, cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain lifecycle event callbacks
|
2010-03-26 13:22:06 +00:00
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), event, detail, opaque)
|
|
|
|
return 0
|
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventGenericCallback(self, dom, cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain generic event callbacks
|
2010-03-26 13:22:06 +00:00
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
2010-03-26 13:22:06 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), opaque)
|
|
|
|
return 0
|
2010-03-26 13:22:06 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventRTCChangeCallback(self, dom, offset, cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain RTC change event callbacks
|
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), offset ,opaque)
|
|
|
|
return 0
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventWatchdogCallback(self, dom, action, cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain watchdog event callbacks
|
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), action, opaque)
|
|
|
|
return 0
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventIOErrorCallback(self, dom, srcPath, devAlias,
|
|
|
|
action, cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain IO error event callbacks
|
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action, opaque)
|
|
|
|
return 0
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventIOErrorReasonCallback(self, dom, srcPath,
|
|
|
|
devAlias, action, reason,
|
|
|
|
cbData):
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
"""Dispatches events to python user domain IO error event callbacks
|
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
Add support for another explicit IO error event
This introduces a new event type
VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
This event is the same as the previous VIR_DOMAIN_ID_IO_ERROR
event, but also includes a string describing the cause of
the event.
Thus there is a new callback definition for this event type
typedef void (*virConnectDomainEventIOErrorReasonCallback)(virConnectPtr conn,
virDomainPtr dom,
const char *srcPath,
const char *devAlias,
int action,
const char *reason,
void *opaque);
This is currently wired up to the QEMU block IO error events
* daemon/remote.c: Dispatch IO error events to client
* examples/domain-events/events-c/event-test.c: Watch for
IO error events
* include/libvirt/libvirt.h.in: Define new IO error event ID
and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Extend API to handle IO error events
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
for block IO errors and emit a libvirt IO error event
* src/remote/remote_driver.c: Receive and dispatch IO error
events to application
* src/remote/remote_protocol.x: Wire protocol definition for
IO error events
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
src/qemu/qemu_monitor_json.c: Watch for BLOCK_IO_ERROR event
from QEMU monitor
2010-03-18 19:37:44 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), srcPath, devAlias, action,
|
|
|
|
reason, opaque)
|
|
|
|
return 0
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
def _dispatchDomainEventGraphicsCallback(self, dom, phase, localAddr,
|
|
|
|
remoteAddr, authScheme, subject,
|
|
|
|
cbData):
|
2010-04-08 15:01:00 +00:00
|
|
|
"""Dispatches events to python user domain graphics event callbacks
|
|
|
|
"""
|
2011-06-16 00:14:45 +00:00
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-06-16 00:14:45 +00:00
|
|
|
cb(self, virDomain(self, _obj=dom), phase, localAddr, remoteAddr,
|
|
|
|
authScheme, subject, opaque)
|
|
|
|
return 0
|
2010-04-08 15:01:00 +00:00
|
|
|
|
2011-07-22 05:57:42 +00:00
|
|
|
def dispatchDomainEventBlockPullCallback(self, dom, path, type, status, cbData):
|
|
|
|
"""Dispatches events to python user domain blockJob event callbacks
|
|
|
|
"""
|
|
|
|
try:
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), path, type, status, opaque)
|
|
|
|
return 0
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
2011-10-18 14:15:42 +00:00
|
|
|
def _dispatchDomainEventDiskChangeCallback(self, dom, oldSrcPath, newSrcPath, devAlias, reason, cbData):
|
|
|
|
"""Dispatches event to python user domain diskChange event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), oldSrcPath, newSrcPath, devAlias, reason, opaque)
|
2013-02-07 07:22:01 +00:00
|
|
|
return 0
|
2011-10-18 14:15:42 +00:00
|
|
|
|
2012-03-23 13:44:50 +00:00
|
|
|
def _dispatchDomainEventTrayChangeCallback(self, dom, devAlias, reason, cbData):
|
|
|
|
"""Dispatches event to python user domain trayChange event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), devAlias, reason, opaque)
|
2013-02-07 07:22:01 +00:00
|
|
|
return 0
|
2012-03-23 13:44:50 +00:00
|
|
|
|
2012-03-23 14:43:14 +00:00
|
|
|
def _dispatchDomainEventPMWakeupCallback(self, dom, reason, cbData):
|
|
|
|
"""Dispatches event to python user domain pmwakeup event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
2013-02-07 07:22:01 +00:00
|
|
|
return 0
|
2012-03-23 13:44:50 +00:00
|
|
|
|
2012-03-23 14:50:36 +00:00
|
|
|
def _dispatchDomainEventPMSuspendCallback(self, dom, reason, cbData):
|
|
|
|
"""Dispatches event to python user domain pmsuspend event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
2013-02-07 07:22:01 +00:00
|
|
|
return 0
|
2012-03-23 14:50:36 +00:00
|
|
|
|
2012-07-13 09:05:17 +00:00
|
|
|
def _dispatchDomainEventBalloonChangeCallback(self, dom, actual, cbData):
|
|
|
|
"""Dispatches events to python user domain balloon change event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), actual, opaque)
|
|
|
|
return 0
|
2012-10-12 19:13:39 +00:00
|
|
|
|
|
|
|
def _dispatchDomainEventPMSuspendDiskCallback(self, dom, reason, cbData):
|
|
|
|
"""Dispatches event to python user domain pmsuspend-disk event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), reason, opaque)
|
2013-02-07 07:22:01 +00:00
|
|
|
return 0
|
2012-07-13 09:05:17 +00:00
|
|
|
|
2013-06-19 13:27:29 +00:00
|
|
|
def _dispatchDomainEventDeviceRemovedCallback(self, dom, devAlias, cbData):
|
|
|
|
"""Dispatches event to python user domain device removed event callbacks
|
|
|
|
"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, virDomain(self, _obj=dom), devAlias, opaque)
|
|
|
|
return 0
|
|
|
|
|
2010-03-26 13:22:06 +00:00
|
|
|
def domainEventDeregisterAny(self, callbackID):
|
|
|
|
"""Removes a Domain Event Callback. De-registering for a
|
|
|
|
domain callback will disable delivery of this event type """
|
|
|
|
try:
|
|
|
|
ret = libvirtmod.virConnectDomainEventDeregisterAny(self._o, callbackID)
|
|
|
|
if ret == -1: raise libvirtError ('virConnectDomainEventDeregisterAny() failed', conn=self)
|
|
|
|
del self.domainEventCallbackID[callbackID]
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def domainEventRegisterAny(self, dom, eventID, cb, opaque):
|
|
|
|
"""Adds a Domain Event Callback. Registering for a domain
|
|
|
|
callback will enable delivery of the events """
|
|
|
|
if not hasattr(self, 'domainEventCallbackID'):
|
|
|
|
self.domainEventCallbackID = {}
|
|
|
|
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
|
|
|
if dom is None:
|
|
|
|
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, None, eventID, cbData)
|
|
|
|
else:
|
|
|
|
ret = libvirtmod.virConnectDomainEventRegisterAny(self._o, dom._o, eventID, cbData)
|
|
|
|
if ret == -1:
|
|
|
|
raise libvirtError ('virConnectDomainEventRegisterAny() failed', conn=self)
|
|
|
|
self.domainEventCallbackID[ret] = opaque
|
2010-07-08 10:30:47 +00:00
|
|
|
return ret
|
2012-05-20 14:20:11 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllDomains(self, flags=0):
|
2012-05-20 14:20:11 +00:00
|
|
|
"""List all domains and returns a list of domain objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllDomains(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllDomains() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for domptr in ret:
|
|
|
|
retlist.append(virDomain(self, _obj=domptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-04 15:16:33 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllStoragePools(self, flags=0):
|
2012-09-04 15:16:33 +00:00
|
|
|
"""Returns a list of storage pool objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllStoragePools(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllStoragePools() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for poolptr in ret:
|
|
|
|
retlist.append(virStoragePool(self, _obj=poolptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-04 15:55:21 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllNetworks(self, flags=0):
|
2012-09-04 15:55:21 +00:00
|
|
|
"""Returns a list of network objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllNetworks(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllNetworks() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for netptr in ret:
|
|
|
|
retlist.append(virNetwork(self, _obj=netptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-04 16:10:19 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllInterfaces(self, flags=0):
|
2012-09-04 16:10:19 +00:00
|
|
|
"""Returns a list of interface objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllInterfaces(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllInterfaces() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for ifaceptr in ret:
|
|
|
|
retlist.append(virInterface(self, _obj=ifaceptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-05 05:34:11 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllDevices(self, flags=0):
|
2012-09-05 05:34:11 +00:00
|
|
|
"""Returns a list of host node device objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllNodeDevices(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllNodeDevices() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for devptr in ret:
|
|
|
|
retlist.append(virNodeDevice(self, _obj=devptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-05 06:02:06 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllNWFilters(self, flags=0):
|
2012-09-05 06:02:06 +00:00
|
|
|
"""Returns a list of network filter objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllNWFilters(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllNWFilters() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for filter_ptr in ret:
|
|
|
|
retlist.append(virNWFilter(self, _obj=filter_ptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-09-14 08:38:51 +00:00
|
|
|
|
python: treat flags as default argument with value 0
The following four functions have not changed because default arguments
have to come after positional arguments. Changing them will break the
the binding APIs.
migrate(self, dconn, flags, dname, uri, bandwidth):
migrate2(self, dconn, dxml, flags, dname, uri, bandwidth):
migrateToURI(self, duri, flags, dname, bandwidth):
migrateToURI2(self, dconnuri, miguri, dxml, flags, dname, bandwidth):
2013-03-21 08:27:09 +00:00
|
|
|
def listAllSecrets(self, flags=0):
|
2012-09-14 08:38:51 +00:00
|
|
|
"""Returns a list of secret objects"""
|
|
|
|
ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
|
|
|
|
if ret is None:
|
|
|
|
raise libvirtError("virConnectListAllSecrets() failed", conn=self)
|
|
|
|
|
|
|
|
retlist = list()
|
|
|
|
for secret_ptr in ret:
|
|
|
|
retlist.append(virSecret(self, _obj=secret_ptr))
|
|
|
|
|
|
|
|
return retlist
|
2012-07-30 16:30:42 +00:00
|
|
|
|
|
|
|
def _dispatchCloseCallback(self, reason, cbData):
|
|
|
|
"""Dispatches events to python user close callback"""
|
|
|
|
cb = cbData["cb"]
|
|
|
|
opaque = cbData["opaque"]
|
|
|
|
|
|
|
|
cb(self, reason, opaque)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def unregisterCloseCallback(self):
|
|
|
|
"""Removes a close event callback"""
|
|
|
|
ret = libvirtmod.virConnectUnregisterCloseCallback(self._o)
|
|
|
|
if ret == -1: raise libvirtError ('virConnectUnregisterCloseCallback() failed', conn=self)
|
|
|
|
|
|
|
|
def registerCloseCallback(self, cb, opaque):
|
|
|
|
"""Adds a close event callback, providing a notification
|
|
|
|
when a connection fails / closes"""
|
|
|
|
cbData = { "cb": cb, "conn": self, "opaque": opaque }
|
|
|
|
ret = libvirtmod.virConnectRegisterCloseCallback(self._o, cbData)
|
|
|
|
if ret == -1:
|
|
|
|
raise libvirtError ('virConnectRegisterCloseCallback() failed', conn=self)
|
|
|
|
return ret
|
Introduce new domain create APIs to pass pre-opened FDs to LXC
With container based virt, it is useful to be able to pass
pre-opened file descriptors to the container init process.
This allows for containers to be auto-activated from incoming
socket connections, passing the active socket into the container.
To do this, introduce a pair of new APIs, virDomainCreateXMLWithFiles
and virDomainCreateWithFiles, which accept an array of file
descriptors. For the LXC driver, UNIX file descriptor passing
will be used to send them to libvirtd, which will them pass
them down to libvirt_lxc, which will then pass them to the container
init process.
This will only be implemented for LXC right now, but the design
is generic enough it could work with other hypervisors, hence
I suggest adding this to libvirt.so, rather than libvirt-lxc.so
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-09 16:12:38 +00:00
|
|
|
|
|
|
|
def createXMLWithFiles(self, xmlDesc, files, flags=0):
|
|
|
|
"""Launch a new guest domain, based on an XML description similar
|
|
|
|
to the one returned by virDomainGetXMLDesc()
|
|
|
|
This function may require privileged access to the hypervisor.
|
|
|
|
The domain is not persistent, so its definition will disappear when it
|
|
|
|
is destroyed, or if the host is restarted (see virDomainDefineXML() to
|
|
|
|
define persistent domains).
|
|
|
|
|
|
|
|
@files provides an array of file descriptors which will be
|
|
|
|
made available to the 'init' process of the guest. The file
|
|
|
|
handles exposed to the guest will be renumbered to start
|
|
|
|
from 3 (ie immediately following stderr). This is only
|
|
|
|
supported for guests which use container based virtualization
|
|
|
|
technology.
|
|
|
|
|
|
|
|
If the VIR_DOMAIN_START_PAUSED flag is set, the guest domain
|
|
|
|
will be started, but its CPUs will remain paused. The CPUs
|
|
|
|
can later be manually started using virDomainResume.
|
|
|
|
|
|
|
|
If the VIR_DOMAIN_START_AUTODESTROY flag is set, the guest
|
|
|
|
domain will be automatically destroyed when the virConnectPtr
|
|
|
|
object is finally released. This will also happen if the
|
|
|
|
client application crashes / loses its connection to the
|
|
|
|
libvirtd daemon. Any domains marked for auto destroy will
|
|
|
|
block attempts at migration, save-to-file, or snapshots. """
|
|
|
|
ret = libvirtmod.virDomainCreateXMLWithFiles(self._o, xmlDesc, files, flags)
|
|
|
|
if ret is None:raise libvirtError('virDomainCreateXMLWithFiles() failed', conn=self)
|
|
|
|
__tmp = virDomain(self,_obj=ret)
|
|
|
|
return __tmp
|