Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
generator.py | 33 ++++++++++++++++++++--
libvirt-override-api.xml | 6 ++++
libvirt-override-virConnect.py | 12 ++++++++
libvirt-override.c | 51 ++++++++++++++++++++++++++++++++++
typewrappers.c | 13 +++++++++
typewrappers.h | 10 +++++++
6 files changed, 122 insertions(+), 3 deletions(-)
diff --git a/generator.py b/generator.py
index 353adab..ae0e45c 100755
--- a/generator.py
+++ b/generator.py
@@ -356,6 +356,10 @@ py_types = {
'virNWFilter *': ('O', "virNWFilter",
"virNWFilterPtr", "virNWFilterPtr"),
'const virNWFilter *': ('O', "virNWFilter",
"virNWFilterPtr", "virNWFilterPtr"),
+ 'virNWFilterBindingPtr': ('O', "virNWFilterBinding",
"virNWFilterBindingPtr", "virNWFilterBindingPtr"),
+ 'virNWFilterBinding *': ('O', "virNWFilterBinding",
"virNWFilterBindingPtr", "virNWFilterBindingPtr"),
+ 'const virNWFilterBinding *': ('O', "virNWFilterBinding",
"virNWFilterBindingPtr", "virNWFilterBindingPtr"),
+
'virStreamPtr': ('O', "virStream",
"virStreamPtr", "virStreamPtr"),
'virStream *': ('O', "virStream",
"virStreamPtr", "virStreamPtr"),
'const virStream *': ('O', "virStream",
"virStreamPtr", "virStreamPtr"),
@@ -539,6 +543,7 @@ skip_function = (
'virConnectListAllInterfaces', # overridden in virConnect.py
'virConnectListAllNodeDevices', # overridden in virConnect.py
'virConnectListAllNWFilters', # overridden in virConnect.py
+ 'virConnectListAllNWFilterBindings', # overridden in virConnect.py
'virConnectListAllSecrets', # overridden in virConnect.py
'virConnectGetAllDomainStats', # overridden in virConnect.py
'virDomainListGetStats', # overriden in virConnect.py
@@ -572,6 +577,7 @@ skip_function = (
"virNodeDeviceRef",
"virSecretRef",
"virNWFilterRef",
+ "virNWFilterBindingRef",
"virStoragePoolRef",
"virStorageVolRef",
"virStreamRef",
@@ -1010,6 +1016,8 @@ classes_type = {
"virSecret *": ("._o", "virSecret(self, _obj=%s)",
"virSecret"),
"virNWFilterPtr": ("._o", "virNWFilter(self, _obj=%s)",
"virNWFilter"),
"virNWFilter *": ("._o", "virNWFilter(self, _obj=%s)",
"virNWFilter"),
+ "virNWFilterBindingPtr": ("._o", "virNWFilterBinding(self,
_obj=%s)", "virNWFilterBinding"),
+ "virNWFilterBinding *": ("._o", "virNWFilterBinding(self,
_obj=%s)", "virNWFilterBinding"),
"virStreamPtr": ("._o", "virStream(self, _obj=%s)",
"virStream"),
"virStream *": ("._o", "virStream(self, _obj=%s)",
"virStream"),
"virConnectPtr": ("._o", "virConnect(_obj=%s)",
"virConnect"),
@@ -1021,7 +1029,8 @@ classes_type = {
primary_classes = ["virDomain", "virNetwork",
"virInterface",
"virStoragePool", "virStorageVol",
"virConnect", "virNodeDevice",
"virSecret",
- "virNWFilter", "virStream",
"virDomainSnapshot"]
+ "virNWFilter", "virNWFilterBinding",
+ "virStream", "virDomainSnapshot"]
classes_destructors = {
"virDomain": "virDomainFree",
@@ -1032,6 +1041,7 @@ classes_destructors = {
"virNodeDevice" : "virNodeDeviceFree",
"virSecret": "virSecretFree",
"virNWFilter": "virNWFilterFree",
+ "virNWFilterBinding": "virNWFilterBindingFree",
"virDomainSnapshot": "virDomainSnapshotFree",
# We hand-craft __del__ for this one
#"virStream": "virStreamFree",
@@ -1058,6 +1068,8 @@ functions_noexcept = {
'virSecretGetUsageType': True,
'virSecretGetUsageID': True,
'virNWFilterGetName': True,
+ 'virNWFilterBindingGetFilterName': True,
+ 'virNWFilterBindingGetPortDev': True,
}
function_classes = {}
@@ -1113,6 +1125,15 @@ def nameFixup(name, classe, type, file):
elif name[0:15] == "virSecretLookup":
func = name[3:]
func = func[0:1].lower() + func[1:]
+ elif name[0:27] == "virNWFilterBindingCreateXML":
+ func = name[3:]
+ func = func[0:1].lower() + func[1:]
+ elif name[0:24] == "virNWFilterBindingDefine":
+ func = name[3:]
+ func = func[0:3].lower() + func[3:]
+ elif name[0:24] == "virNWFilterBindingLookup":
+ func = name[3:]
+ func = func[0:3].lower() + func[3:]
elif name[0:17] == "virNWFilterDefine":
func = name[3:]
func = func[0:3].lower() + func[3:]
@@ -1189,6 +1210,12 @@ def nameFixup(name, classe, type, file):
elif name[0:9] == 'virSecret':
func = name[9:]
func = func[0:1].lower() + func[1:]
+ elif name[0:21] == 'virNWFilterBindingGet':
+ func = name[21:]
+ func = func[0:1].lower() + func[1:]
+ elif name[0:18] == 'virNWFilterBinding':
+ func = name[18:]
+ func = func[0:1].lower() + func[1:]
elif name[0:14] == 'virNWFilterGet':
func = name[14:]
func = func[0:1].lower() + func[1:]
@@ -1468,7 +1495,7 @@ def buildWrappers(module):
classes.write("class %s(object):\n" % (classname))
if classname in [ "virDomain", "virNetwork",
"virInterface", "virStoragePool",
"virStorageVol", "virNodeDevice",
"virSecret","virStream",
- "virNWFilter" ]:
+ "virNWFilter", "virNWFilterBinding" ]:
classes.write(" def __init__(self, conn, _obj=None):\n")
elif classname in [ 'virDomainSnapshot' ]:
classes.write(" def __init__(self, dom, _obj=None):\n")
@@ -1476,7 +1503,7 @@ def buildWrappers(module):
classes.write(" def __init__(self, _obj=None):\n")
if classname in [ "virDomain", "virNetwork",
"virInterface",
"virNodeDevice", "virSecret",
"virStream",
- "virNWFilter" ]:
+ "virNWFilter", "virNWFilterBinding" ]:
classes.write(" self._conn = conn\n")
elif classname in [ "virStorageVol", "virStoragePool" ]:
classes.write(" self._conn = conn\n" + \
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index ecbdac2..4e8d6c0 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -485,6 +485,12 @@
<arg name='flags' type='unsigned int' info='optional
flags'/>
<return type='char *' info='the list of network filters or None in
case of error'/>
</function>
+ <function name='virConnectListAllNWFilterBindings'
file='python'>
+ <info>returns list of all network fitler bindings</info>
+ <arg name='conn' type='virConnectPtr' info='pointer to the
hypervisor connection'/>
+ <arg name='flags' type='unsigned int' info='optional
flags'/>
+ <return type='char *' info='the list of network filter bindings or
None in case of error'/>
+ </function>
<function name='virNWFilterLookupByUUID' file='python'>
<info>Try to lookup a network filter on the given hypervisor based on its
UUID.</info>
<return type='virNWFilterPtr' info='a new network filter object or
NULL in case of failure'/>
diff --git a/libvirt-override-virConnect.py b/libvirt-override-virConnect.py
index a24eae7..7fe08e0 100644
--- a/libvirt-override-virConnect.py
+++ b/libvirt-override-virConnect.py
@@ -531,6 +531,18 @@
return retlist
+ def listAllNWFilterBindings(self, flags=0):
+ """Returns a list of network filter binding
objects"""
+ ret = libvirtmod.virConnectListAllNWFilterBindings(self._o, flags)
+ if ret is None:
+ raise libvirtError("virConnectListAllNWFilterBindings() failed",
conn=self)
+
+ retlist = list()
+ for filter_ptr in ret:
+ retlist.append(virNWFilterBinding(self, _obj=filter_ptr))
+
+ return retlist
+
def listAllSecrets(self, flags=0):
"""Returns a list of secret objects"""
ret = libvirtmod.virConnectListAllSecrets(self._o, flags)
diff --git a/libvirt-override.c b/libvirt-override.c
index 012de3f..e74c7dd 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -4446,6 +4446,54 @@ libvirt_virConnectListAllNWFilters(PyObject *self
ATTRIBUTE_UNUSED,
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
+#if LIBVIR_CHECK_VERSION(4, 5, 0)
+static PyObject *
+libvirt_virConnectListAllNWFilterBindings(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *pyobj_conn;
+ PyObject *py_retval = NULL;
+ virConnectPtr conn;
+ virNWFilterBindingPtr *bindings = NULL;
+ int c_retval = 0;
+ ssize_t i;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char
*)"OI:virConnectListAllNWFilterBindings",
+ &pyobj_conn, &flags))
+ return NULL;
+ conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virConnectListAllNWFilterBindings(conn, &bindings, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+
+ if (!(py_retval = PyList_New(c_retval)))
+ goto cleanup;
+
+ for (i = 0; i < c_retval; i++) {
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virNWFilterBindingPtrWrap(bindings[i]), error);
+ /* python steals the pointer */
+ bindings[i] = NULL;
+ }
+
+ cleanup:
+ for (i = 0; i < c_retval; i++)
+ if (bindings[i])
+ virNWFilterBindingFree(bindings[i]);
+ VIR_FREE(bindings);
+ return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
+}
+#endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
+
static PyObject *
libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args)
@@ -9971,6 +10019,9 @@ static PyMethodDef libvirtMethods[] = {
#if LIBVIR_CHECK_VERSION(0, 10, 2)
{(char *) "virConnectListAllNWFilters", libvirt_virConnectListAllNWFilters,
METH_VARARGS, NULL},
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
+#if LIBVIR_CHECK_VERSION(4, 5, 0)
+ {(char *) "virConnectListAllNWFilterBindings",
libvirt_virConnectListAllNWFilterBindings, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(4, 5, 0) */
{(char *) "virConnectListInterfaces", libvirt_virConnectListInterfaces,
METH_VARARGS, NULL},
{(char *) "virConnectListDefinedInterfaces",
libvirt_virConnectListDefinedInterfaces, METH_VARARGS, NULL},
#if LIBVIR_CHECK_VERSION(0, 10, 2)
diff --git a/typewrappers.c b/typewrappers.c
index 99a8fb8..9ba14b4 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -542,6 +542,19 @@ libvirt_virNWFilterPtrWrap(virNWFilterPtr node)
return ret;
}
+PyObject *
+libvirt_virNWFilterBindingPtrWrap(virNWFilterBindingPtr node)
+{
+ PyObject *ret;
+
+ if (node == NULL) {
+ return VIR_PY_NONE;
+ }
+
+ ret = libvirt_buildPyObject(node, "virNWFilterBindingPtr", NULL);
+ return ret;
+}
+
PyObject *
libvirt_virStreamPtrWrap(virStreamPtr node)
{
diff --git a/typewrappers.h b/typewrappers.h
index ed1e4a3..1570c6a 100644
--- a/typewrappers.h
+++ b/typewrappers.h
@@ -106,6 +106,15 @@ typedef struct {
} PyvirNWFilter_Object;
+#define PyvirNWFilterBinding_Get(v) (((v) == Py_None) ? NULL : \
+ (((PyvirNWFilterBinding_Object *)(v))->obj))
+
+typedef struct {
+ PyObject_HEAD
+ virNWFilterBindingPtr obj;
+} PyvirNWFilterBinding_Object;
+
+
#define PyvirStream_Get(v) (((v) == Py_None) ? NULL : \
(((PyvirStream_Object *)(v))->obj))
@@ -189,6 +198,7 @@ PyObject * libvirt_virVoidPtrWrap(void* node);
PyObject * libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node);
PyObject * libvirt_virSecretPtrWrap(virSecretPtr node);
PyObject * libvirt_virNWFilterPtrWrap(virNWFilterPtr node);
+PyObject * libvirt_virNWFilterBindingPtrWrap(virNWFilterBindingPtr node);
PyObject * libvirt_virStreamPtrWrap(virStreamPtr node);
PyObject * libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node);
--
2.17.1